blob: ecc306a73392b00b18a70cf6ba3fb01965666a6c [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 ]
13
14 windows_keydefs = {
15 '<<zoom-height>>': ['<Alt-F2>'],
16 }
17 unix_keydefs = {
18 '<<zoom-height>>': ['<Control-x><Control-z>'],
19 }
20
21 def __init__(self, editwin):
22 self.editwin = editwin
23
24 def zoom_height_event(self, event):
25 top = self.editwin.top
26 zoom_height(top)
27
28def zoom_height(top):
29 geom = top.wm_geometry()
30 m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
31 if not m:
32 top.bell()
33 return
34 width, height, x, y = map(int, m.groups())
35 newheight = top.winfo_screenheight()
36 if sys.platform == 'win32':
37 newy = 0
38 newheight = newheight - 72
39 else:
40 newy = 24
41 newheight = newheight - 96
42 if height >= newheight:
43 newgeom = ""
44 else:
45 newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
46 top.wm_geometry(newgeom)