~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Lib/idlelib/ZoomHeight.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Sample extension: zoom a window to maximum height
 
2
 
 
3
import re
 
4
import sys
 
5
 
 
6
from idlelib import macosxSupport
 
7
 
 
8
class ZoomHeight:
 
9
 
 
10
    menudefs = [
 
11
        ('windows', [
 
12
            ('_Zoom Height', '<<zoom-height>>'),
 
13
         ])
 
14
    ]
 
15
 
 
16
    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
 
 
23
def 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
 
34
 
 
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.
 
39
        newy = 22
 
40
        newheight = newheight - newy - 88
 
41
 
 
42
    else:
 
43
        #newy = 24
 
44
        newy = 0
 
45
        #newheight = newheight - 96
 
46
        newheight = newheight - 88
 
47
    if height >= newheight:
 
48
        newgeom = ""
 
49
    else:
 
50
        newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
 
51
    top.wm_geometry(newgeom)