From Vasilis.Vlachoudis at cern.ch Tue Feb 22 03:42:33 2022 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Tue, 22 Feb 2022 08:42:33 +0000 Subject: [Tkinter-discuss] How to center tkDialog Message-ID: <0BC70B5D93E054469872FFD0FE07220E033860D835@CERNXCHG53.cern.ch> Hi all, when using the tkDialogs.Dialog(), it always appears centered in the screen and not as on-top/transient of the master window. In contrast with the other dialogs it doesn't seem to respect the parent= any ideas on how to center it? Vasilis -------------- next part -------------- An HTML attachment was scrubbed... URL: From Vasilis.Vlachoudis at cern.ch Tue Feb 22 04:39:32 2022 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Tue, 22 Feb 2022 09:39:32 +0000 Subject: [Tkinter-discuss] How to center tkDialog In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E033860D835@CERNXCHG53.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E033860D835@CERNXCHG53.cern.ch> Message-ID: <0BC70B5D93E054469872FFD0FE07220E033860E8C2@CERNXCHG53.cern.ch> For some reason the "transient()" is not enough to center the window. I was looking the code of the msgbox.tcl (Messagebox) and there is a command ::tk::PlaceWindow $w widget $data(-parent) Using this command it centers the dialog e.g. root = tk.Tk() t2 = tk.Toplevel(root) t2.transient(root) tk.Label(t2, text='This is a transient window of root').pack(padx=10, pady=10) # root.tk.call("::tk::PlaceWindow", t2, "widget", root) root.mainloop() as is the dialog is centered wrt the screen, when you uncomment the PlaceWindow command it is properly placed on top of the root window ________________________________ From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Vasilis Vlachoudis [Vasilis.Vlachoudis at cern.ch] Sent: Tuesday, February 22, 2022 09:42 To: tkinter-discuss at python.org Subject: [Tkinter-discuss] How to center tkDialog Hi all, when using the tkDialogs.Dialog(), it always appears centered in the screen and not as on-top/transient of the master window. In contrast with the other dialogs it doesn't seem to respect the parent= any ideas on how to center it? Vasilis -------------- next part -------------- An HTML attachment was scrubbed... URL: