home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / ZoomHeight.py < prev    next >
Text File  |  2003-12-30  |  958b  |  42 lines

  1. # Sample extension: zoom a window to maximum height
  2.  
  3. import re
  4. import sys
  5.  
  6. class ZoomHeight:
  7.  
  8.     menudefs = [
  9.         ('windows', [
  10.             ('_Zoom Height', '<<zoom-height>>'),
  11.          ])
  12.     ]
  13.  
  14.     def __init__(self, editwin):
  15.         self.editwin = editwin
  16.  
  17.     def zoom_height_event(self, event):
  18.         top = self.editwin.top
  19.         zoom_height(top)
  20.  
  21. def zoom_height(top):
  22.     geom = top.wm_geometry()
  23.     m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
  24.     if not m:
  25.         top.bell()
  26.         return
  27.     width, height, x, y = map(int, m.groups())
  28.     newheight = top.winfo_screenheight()
  29.     if sys.platform == 'win32':
  30.         newy = 0
  31.         newheight = newheight - 72
  32.     else:
  33.         #newy = 24
  34.         newy = 0
  35.         #newheight = newheight - 96
  36.         newheight = newheight - 88
  37.     if height >= newheight:
  38.         newgeom = ""
  39.     else:
  40.         newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy)
  41.     top.wm_geometry(newgeom)
  42.