Apr-25-2021, 02:16 AM
(Apr-25-2021, 01:59 AM)BashBedlam Wrote: In this example, the text_entry widget is set to have focus as soon as the toplevel window opens. Is this what you're looking for?
from tkinter import Tk, Toplevel, Button, Label, Text def open_a_toplevel_window () : toplevel_window = Toplevel (root) toplevel_window.title ('Focusing on Text Entery') toplevel_window.geometry ('270x100') label = Label(toplevel_window, text = 'Enter Text Now') label.pack() text_entry = Text (toplevel_window, width = 10, height = 3) text_entry.focus_set () text_entry.pack () toplevel_window.attributes ('-topmost', True) toplevel_window.mainloop() root = Tk () root.title ("Root Window") root.geometry ("400x200") label1 = Label (root, text = "This is the Root Window") button = Button (root, text = "Open Toplevel Window") button.config (command = open_a_toplevel_window) label1.pack () button.place (x = 110, y = 50) root.mainloop ()
That is playing more nicely. Many thanks.