Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default entry field in tkinter with python

I'm writing a small app using tkinter and Python to create a popup and ask for some input.

Currently I have to click on the text field before I can enter data. As there is only one text field I would like to just be able to type and the text field to be automatically active and ready to accept input, without having to first select the field.

How might I achieve this?

like image 917
Slipstream Avatar asked Dec 06 '25 15:12

Slipstream


1 Answers

If textfield is the Text object, call textfield.focus() to make the text field automatically active.

import tkinter as tk

root = tk.Tk()
textfield = tk.Text(root)
textfield.pack()
textfield.focus()
root.mainloop()
like image 139
unutbu Avatar answered Dec 08 '25 04:12

unutbu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!