# HG changeset patch # User drewp # Date 2002-07-12 11:08:20 # Node ID 09b3bf8a9201433893bd8d9c41faac9a971e1b97 # Parent ae2ed47a5321cd9c76c846716560dae08c79c617 fixed window geometry finally diff --git a/light8/uihelpers.py b/light8/uihelpers.py --- a/light8/uihelpers.py +++ b/light8/uihelpers.py @@ -26,11 +26,33 @@ def bindkeys(root,key, func): for w in root.winfo_children(): w.bind(key, func) + +def toplevel_savegeometry(tl,name): + try: + f=open(".light9-window-geometry-%s" % name.replace(' ','_'),'w') + f.write(tl.geometry()) + except: + # it's ok if there's no saved geometry + pass + + # this would get called repeatedly for each child of the window (i + # dont know why) so we unbind after the first Destroy event + tl.unbind("",tl._toplevelat_funcid) + def toplevelat(name): tl = Toplevel() + try: + f=open(".light9-window-geometry-%s" % name.replace(' ','_')) + windowlocations[name]=f.read() # file has no newline + except: + # it's ok if there's no saved geometry + pass + if name in windowlocations: - tl.wm_geometry(windowlocations[name]) + tl.geometry(windowlocations[name]) + + tl._toplevelat_funcid=tl.bind("",lambda ev,tl=tl,name=name: toplevel_savegeometry(tl,name)) return tl