Mercurial > code > home > repos > light9
comparison light8/uihelpers.py @ 84:09b3bf8a9201
fixed window geometry finally
author | drewp |
---|---|
date | Fri, 12 Jul 2002 11:08:20 +0000 |
parents | 0969d8a6729d |
children | d34a4956417a |
comparison
equal
deleted
inserted
replaced
83:ae2ed47a5321 | 84:09b3bf8a9201 |
---|---|
24 def bindkeys(root,key, func): | 24 def bindkeys(root,key, func): |
25 root.bind(key, func) | 25 root.bind(key, func) |
26 for w in root.winfo_children(): | 26 for w in root.winfo_children(): |
27 w.bind(key, func) | 27 w.bind(key, func) |
28 | 28 |
29 | |
30 def toplevel_savegeometry(tl,name): | |
31 try: | |
32 f=open(".light9-window-geometry-%s" % name.replace(' ','_'),'w') | |
33 f.write(tl.geometry()) | |
34 except: | |
35 # it's ok if there's no saved geometry | |
36 pass | |
37 | |
38 # this would get called repeatedly for each child of the window (i | |
39 # dont know why) so we unbind after the first Destroy event | |
40 tl.unbind("<Destroy>",tl._toplevelat_funcid) | |
41 | |
29 def toplevelat(name): | 42 def toplevelat(name): |
30 tl = Toplevel() | 43 tl = Toplevel() |
31 | 44 |
45 try: | |
46 f=open(".light9-window-geometry-%s" % name.replace(' ','_')) | |
47 windowlocations[name]=f.read() # file has no newline | |
48 except: | |
49 # it's ok if there's no saved geometry | |
50 pass | |
51 | |
32 if name in windowlocations: | 52 if name in windowlocations: |
33 tl.wm_geometry(windowlocations[name]) | 53 tl.geometry(windowlocations[name]) |
54 | |
55 tl._toplevelat_funcid=tl.bind("<Destroy>",lambda ev,tl=tl,name=name: toplevel_savegeometry(tl,name)) | |
34 | 56 |
35 return tl | 57 return tl |
36 | 58 |
37 def toggle_slider(s): | 59 def toggle_slider(s): |
38 if s.get() == 0: | 60 if s.get() == 0: |