0001 # Sample extension: zoom a window to maximum height 0002 0003 import re 0004 import sys 0005 0006 class ZoomHeight: 0007 0008 menudefs = [ 0009 ('windows', [ 0010 ('_Zoom Height', '<<zoom-height>>'), 0011 ]) 0012 ] 0013 0014 def __init__(self, editwin): 0015 self.editwin = editwin 0016 0017 def zoom_height_event(self, event): 0018 top = self.editwin.top 0019 zoom_height(top) 0020 0021 def zoom_height(top): 0022 geom = top.wm_geometry() 0023 m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom) 0024 if not m: 0025 top.bell() 0026 return 0027 width, height, x, y = map(int, m.groups()) 0028 newheight = top.winfo_screenheight() 0029 if sys.platform == 'win32': 0030 newy = 0 0031 newheight = newheight - 72 0032 else: 0033 #newy = 24 0034 newy = 0 0035 #newheight = newheight - 96 0036 newheight = newheight - 88 0037 if height >= newheight: 0038 newgeom = "" 0039 else: 0040 newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy) 0041 top.wm_geometry(newgeom) 0042
Generated by PyXR 0.9.4