1 # Sample extension: zoom a window to maximum height
6 from idlelib
import macosxSupport
12 ('_Zoom Height', '<<zoom-height>>'),
16 def __init__(self
, editwin
):
17 self
.editwin
= editwin
19 def zoom_height_event(self
, event
):
20 top
= self
.editwin
.top
24 geom
= top
.wm_geometry()
25 m
= re
.match(r
"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom
)
29 width
, height
, x
, y
= map(int, m
.groups())
30 newheight
= top
.winfo_screenheight()
31 if sys
.platform
== 'win32':
33 newheight
= newheight
- 72
35 elif macosxSupport
.runningAsOSXApp():
36 # 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.
40 newheight
= newheight
- newy
- 88
45 #newheight = newheight - 96
46 newheight
= newheight
- 88
47 if height
>= newheight
:
50 newgeom
= "%dx%d+%d+%d" % (width
, newheight
, x
, newy
)
51 top
.wm_geometry(newgeom
)