Placing child window relative to parent in Tkinter python
The short answer is, use winfo_rootx
and winfo_rooty
to get the coordinates relative to the screen. And yes, wm_geometry
is the way to place a toplevel window precisely.
For example:
x = parentWgdt.winfo_rootx()
y = parentWgdt.winfo_rooty()
height = parentWgdt.winfo_height()
geom = "+%d+%d" % (x,y+height)
As a bit of friendly advice, I recommend against abbrev var nms. It makes the code hard to read, especially when the abbreviation is wrong (Wgdt should at least be Wdgt). The difference in code size between geom
and geometry
, and Wgdt
and Widget
are tiny, but the difference in readability is huge.