I wrote a little program a while back that changes windows a lot and I was wondering if there is a way to have one window open at the same spot the last window closed?

See geometry strings here. "Geometry" sets the size and location of a widget.

I guess I phrased my question badly I want the window to be opened where ever the user dragged the last one to. I know how to control size and position I was hoping to track where it got moved to. such as if it starts at

root.geometry('50x150+100+100')

and then gets moved to

root.geometry('50x150+125+99')

is there a way to find the window location before closing?

well I found this

root.protocol("WM_DELETE_WINDOW", handler)

def handler():
    print "good bye"

but I can't find the window position when it was closed

Search for something like geometry in Tkinter's winfo, which you would have to call at the time the first window closes. I've never done anything like this so am not sure if it will work or not, so post back with any success or failure for future question.

info_window = {}

info_window["x"] = root.winfo_x()
info_window["y"] = root.winfo_y()
root.destroy()

root.geometry('300x200+%d+%d' % (info_window["x"], info_window["y"]))

thanks for the help woooee

Good to know that it worked. It is now in my notes for any future questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.