ยปCore Development>Code coverage>Lib/idlelib/zoomheight.py

Python code coverage for Lib/idlelib/zoomheight.py

#countcontent
1n/a# Sample extension: zoom a window to maximum height
2n/a
3n/aimport re
4n/aimport sys
5n/a
6n/afrom idlelib import macosx
7n/a
8n/a
9n/aclass ZoomHeight:
10n/a
11n/a menudefs = [
12n/a ('windows', [
13n/a ('_Zoom Height', '<<zoom-height>>'),
14n/a ])
15n/a ]
16n/a
17n/a def __init__(self, editwin):
18n/a self.editwin = editwin
19n/a
20n/a def zoom_height_event(self, event):
21n/a top = self.editwin.top
22n/a zoom_height(top)
23n/a
24n/a
25n/adef zoom_height(top):
26n/a geom = top.wm_geometry()
27n/a m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
28n/a if not m:
29n/a top.bell()
30n/a return
31n/a width, height, x, y = map(int, m.groups())
32n/a newheight = top.winfo_screenheight()
33n/a if sys.platform == 'win32':
34n/a newy = 0
35n/a newheight = newheight - 72
36n/a
37n/a elif macosx.isAquaTk():
38n/a # The '88' below is a magic number that avoids placing the bottom
39n/a # of the window below the panel on my machine. I don't know how
40n/a # to calculate the correct value for this with tkinter.
41n/a newy = 22
42n/a newheight = newheight - newy - 88
43n/a
44n/a else:
45n/a #newy = 24
46n/a newy = 0
47n/a #newheight = newheight - 96
48n/a newheight = newheight - 88
49n/a if height >= newheight:
50n/a newgeom = ""
51n/a else:
52n/a newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
53n/a top.wm_geometry(newgeom)