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