Class around PixMap objects that allows more python-like access. By Joe Strout.
[python/dscho.git] / Tools / idle / ZoomHeight.py
blob0aefea63375f0f426e9261b01b8422cfe31631dc
1 # Sample extension: zoom a window to maximum height
3 import re
4 import sys
6 class ZoomHeight:
8 menudefs = [
9 ('windows', [
10 ('_Zoom Height', '<<zoom-height>>'),
14 windows_keydefs = {
15 '<<zoom-height>>': ['<Alt-F2>'],
17 unix_keydefs = {
18 '<<zoom-height>>': ['<Control-x><Control-z>'],
21 def __init__(self, editwin):
22 self.editwin = editwin
24 def zoom_height_event(self, event):
25 top = self.editwin.top
26 geom = top.wm_geometry()
27 m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
28 if not m:
29 top.bell()
30 return
31 width, height, x, y = map(int, m.groups())
32 newheight = top.winfo_screenheight()
33 if sys.platform == 'win32':
34 newy = 0
35 newheight = newheight - 72
36 else:
37 newy = 24
38 newheight = newheight - 96
39 if height >= newheight:
40 newgeom = ""
41 else:
42 newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
43 top.wm_geometry(newgeom)