Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / lib / python2.4 / idlelib / ZoomHeight.py
CommitLineData
920dae64
AT
1# 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 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:
33 #newy = 24
34 newy = 0
35 #newheight = newheight - 96
36 newheight = newheight - 88
37 if height >= newheight:
38 newgeom = ""
39 else:
40 newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
41 top.wm_geometry(newgeom)