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?
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With