1999-01-02 17:28:54 -04:00
|
|
|
# Sample extension: zoom a window to maximum height
|
|
|
|
|
|
|
|
import re
|
1999-01-02 20:47:07 -04:00
|
|
|
import sys
|
1999-01-02 17:28:54 -04:00
|
|
|
|
|
|
|
class ZoomHeight:
|
|
|
|
|
|
|
|
menudefs = [
|
|
|
|
('windows', [
|
|
|
|
('_Zoom Height', '<<zoom-height>>'),
|
|
|
|
])
|
|
|
|
]
|
|
|
|
|
|
|
|
windows_keydefs = {
|
|
|
|
'<<zoom-height>>': ['<Alt-F2>'],
|
|
|
|
}
|
|
|
|
unix_keydefs = {
|
1999-01-02 20:47:07 -04:00
|
|
|
'<<zoom-height>>': ['<Control-x><Control-z>'],
|
1999-01-02 17:28:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self, editwin):
|
|
|
|
self.editwin = editwin
|
|
|
|
|
|
|
|
def zoom_height_event(self, event):
|
|
|
|
top = self.editwin.top
|
|
|
|
geom = top.wm_geometry()
|
|
|
|
m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
|
|
|
|
if not m:
|
|
|
|
top.bell()
|
|
|
|
return
|
|
|
|
width, height, x, y = map(int, m.groups())
|
1999-01-02 20:47:07 -04:00
|
|
|
height = top.winfo_screenheight()
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
y = 0
|
1999-01-04 08:23:46 -04:00
|
|
|
height = height - 72
|
1999-01-02 20:47:07 -04:00
|
|
|
else:
|
|
|
|
y = 24
|
|
|
|
height = height - 64
|
|
|
|
newgeom = "%dx%d+%d+%d" % (width, height, x, y)
|
1999-01-02 17:28:54 -04:00
|
|
|
if geom == newgeom:
|
|
|
|
newgeom = ""
|
|
|
|
top.wm_geometry(newgeom)
|