How do I give focus to a python Tkinter text widget?
18,679
You use the focus_set
method. For example:
from Tkinter import *
root = Tk()
Window = Frame(root)
TextWidget = Text(Window)
TextWidget.pack()
Window.pack()
TextWidget.focus_set()
root.mainloop()
Related videos on Youtube
Author by
Symon
Updated on March 19, 2020Comments
-
Symon about 4 years
I'd like to be able to open the App GUI and have it automatically place the cursor into a particular text widget. Best case scenario is: as soon as the app is launched someone can start typing without having to click on the text widget. This is just a small example displaying the issue:
from Tkinter import * root = Tk() Window = Frame(root) TextWidget = Text(Window) TextWidget.pack() Window.pack() root.mainloop()
-
Symon about 13 yearsThat's exactly what I was looking for, I can't believe I missed it :). Thanks.