blob: 2ab4656e4cfaafb00c73fee0b6e71521906b0497 [file] [log] [blame]
David Scherer7aced172000-08-15 01:13:23 +00001# Sample extension: zoom a window to maximum height
2
3import re
4import sys
5
6class ZoomHeight:
7
8 menudefs = [
9 ('windows', [
10 ('_Zoom Height', '<<zoom-height>>'),
11 ])
12 ]
Kurt B. Kaiser6655e4b2002-12-31 16:03:23 +000013
David Scherer7aced172000-08-15 01:13:23 +000014 def __init__(self, editwin):
15 self.editwin = editwin
16
17 def zoom_height_event(self, event):
18 top = self.editwin.top
19 zoom_height(top)
20
21def zoom_height(top):
22 geom = top.wm_geometry()
23 m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
24 if not m:
25 top.bell()
26 return
27 width, height, x, y = map(int, m.groups())
28 newheight = top.winfo_screenheight()
29 if sys.platform == 'win32':
30 newy = 0
31 newheight = newheight - 72
32 else:
Kurt B. Kaiserd0e29262002-12-20 01:22:01 +000033 #newy = 24
34 newy = 0
35 #newheight = newheight - 96
Kurt B. Kaiser6655e4b2002-12-31 16:03:23 +000036 newheight = newheight - 88
David Scherer7aced172000-08-15 01:13:23 +000037 if height >= newheight:
38 newgeom = ""
39 else:
40 newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
41 top.wm_geometry(newgeom)