home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / native / win / winextensions.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  2.8 KB  |  71 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from peak.util.imports import lazyModule, whenImported
  5. wx = lazyModule('wx')
  6. os = lazyModule('os')
  7. wintypes = lazyModule('ctypes.wintypes')
  8. from threading import Thread
  9. from logging import getLogger
  10. log = getLogger('winextensions')
  11. import traceback
  12.  
  13. def browse(url):
  14.     
  15.     def go():
  16.         
  17.         try:
  18.             os.startfile(url)
  19.         except WindowsError:
  20.             if hasattr(traceback, 'print_exc_once'):
  21.                 traceback.print_exc_once()
  22.             else:
  23.                 traceback.print_exc()
  24.             log.error('could not open browser for url: %r', url)
  25.             _fire_browser_error_popup()
  26.  
  27.  
  28.     t = Thread(target = go)
  29.     t.setDaemon(True)
  30.     t.start()
  31.  
  32. wx.LaunchDefaultBrowser = browse
  33.  
  34. def _fire_browser_error_popup():
  35.     fire = fire
  36.     import common
  37.     fire('error', title = 'Error Launching Default Browser', msg = "No default web browser set in Windows. Please check your web browser's preferences.", details = '')
  38.  
  39.  
  40. def wxRectToRECT(rect):
  41.     r = wintypes.RECT()
  42.     r.left = rect.X
  43.     r.top = rect.Y
  44.     r.right = rect.X + rect.Width
  45.     r.bottom = rect.Y + rect.Height
  46.     return r
  47.  
  48.  
  49. def wxRectFromRECT(rect):
  50.     return wx.Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top)
  51.  
  52.  
  53. def GetRECT(win):
  54.     return wxRectToRECT(win.Rect)
  55.  
  56.  
  57. def GetLRECT(win):
  58.     return wxRectToRECT(wx.RectS(win.GetSize()))
  59.  
  60.  
  61. def _monkeypatch(*a, **k):
  62.     WindowClass = None if wx.WXPY else wx.Window
  63.     WindowClass.GetRECT = GetRECT
  64.     WindowClass.RECT = property(GetRECT)
  65.     WindowClass.GetLRECT = GetLRECT
  66.     WindowClass.LRECT = property(GetLRECT)
  67.     wx.Rect.FromRECT = staticmethod(wxRectFromRECT)
  68.     wx.Rect.RECT = property(wxRectToRECT)
  69.  
  70. whenImported('wx', _monkeypatch)
  71.