blob: a5d679e49912b5e4a9ade7340beb46c8aba17a2c [file] [log] [blame]
David Scherer7aced172000-08-15 01:13:23 +00001# Sample extension: zoom a window to maximum height
2
3import re
4import sys
Florent Xiclunad630c042010-04-02 07:24:52 +00005
6from idlelib import macosxSupport
David Scherer7aced172000-08-15 01:13:23 +00007
8class ZoomHeight:
9
10 menudefs = [
11 ('windows', [
12 ('_Zoom Height', '<<zoom-height>>'),
13 ])
14 ]
Kurt B. Kaiser6655e4b2002-12-31 16:03:23 +000015
David Scherer7aced172000-08-15 01:13:23 +000016 def __init__(self, editwin):
17 self.editwin = editwin
18
19 def zoom_height_event(self, event):
20 top = self.editwin.top
21 zoom_height(top)
22
23def zoom_height(top):
24 geom = top.wm_geometry()
25 m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
26 if not m:
27 top.bell()
28 return
29 width, height, x, y = map(int, m.groups())
30 newheight = top.winfo_screenheight()
31 if sys.platform == 'win32':
32 newy = 0
33 newheight = newheight - 72
Ronald Oussoren19302d92006-06-11 14:33:36 +000034
Ned Deily57847df2014-03-27 20:47:04 -070035 elif macosxSupport.isAquaTk():
Ronald Oussoren19302d92006-06-11 14:33:36 +000036 # The '88' below is a magic number that avoids placing the bottom
37 # of the window below the panel on my machine. I don't know how
38 # to calculate the correct value for this with tkinter.
39 newy = 22
40 newheight = newheight - newy - 88
41
David Scherer7aced172000-08-15 01:13:23 +000042 else:
Kurt B. Kaiserd0e29262002-12-20 01:22:01 +000043 #newy = 24
44 newy = 0
45 #newheight = newheight - 96
Kurt B. Kaiser6655e4b2002-12-31 16:03:23 +000046 newheight = newheight - 88
David Scherer7aced172000-08-15 01:13:23 +000047 if height >= newheight:
48 newgeom = ""
49 else:
50 newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
51 top.wm_geometry(newgeom)