I have a parent widget which contains a button. When the button is pressed I would like to open a borderless (i.e. no Windows decoration buttons) window directly underneath the parent widget aligned to the left hand side of it. I'm puzzled that the only way (it seems) of setting the position of a window is using .geometry()
but worse, I can't seem to get the absolute coordinates of the parent widget - which I need for .geometry()
, only the offsets from the parent's parent. So far my code is:
# This is the child which appears when the button is pressed.
class ChildPopUpWindow(Frame):
def __init__(self, parentWgdt):
win = Toplevel(parentWgdt)
geom = str(parentWgdt.winfo_x()) + '+' + str(parentWgdt.winfo_y() + parentWgdt.winfo_height())
win.overrideredirect(1) # No win decoration.
win.bd = 10
win.relief = GROOVE
win.geometry( geom )
Frame.__init__(self, win)
# etc. etc.
# ... and this is the handler for the button being pressed.
def onDropDown(self):
popUp = ChildPopUpWindow(self)
This does pop up a window but relative to the desktop, not to the parent widget. It also seems to take no account of the border thickness and relief as far as I can see. Can anyone offer a way that this can be done? Is .geometry()
the way to go or are there better ways?
onDropDown
is a handler from the frame in which the button resides. On clicking the button, the idea is to pop up a frameless (i.e. no Windows maximise / minimise / close buttons etc.) directly underneath the frame with the button. This would act essentially in a modal way except that either a selection on the pop-up, or pressing the button again, would close it. In this way it would work a bit like say a calendar or colour picker dropdown. – DoggettChildPopUpWindow
class. Please feel ffree to comment / correct. – Doggett