How to position topLevel() widget relative to root window?

Viewed 12689

I have created a topLevel widget and was wondering if there was a way to position the new window relative to the root window.

2 Answers

You can skip getting/setting the dialog width/height and set only its X, Y position:

x = root.winfo_x()
y = root.winfo_y()
toplevel.geometry("+%d+%d" % (x + 100, y + 200)))

Replace 100 and 200 with relative X, Y to your root window.

Related