home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / wxextensions.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  6.3 KB  |  178 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import new
  5. import traceback
  6.  
  7. def SetMinHeight(self, h):
  8.     self.minHeight = h
  9.     if h != -1 and self.GetSize().height < h:
  10.         self.SetSize((-1, h))
  11.     
  12.  
  13.  
  14. def GetMinHeight(self):
  15.     return self.minHeight
  16.  
  17. import wx.lib.expando as wx
  18. wx.lib.expando.ExpandoTextCtrl.SetMinHeight = SetMinHeight
  19. wx.lib.expando.ExpandoTextCtrl.GetMinHeight = GetMinHeight
  20.  
  21. wx.lib.expando.ExpandoTextCtrl.GetExtraHeight = lambda self: self.extraHeight
  22. del SetMinHeight
  23. del GetMinHeight
  24. import cgui
  25. if hasattr(cgui, 'TextCtrlAutoComplete'):
  26.     wx.TextCtrl.AutoComplete = new.instancemethod(cgui.TextCtrlAutoComplete, None, wx.TextCtrl)
  27.  
  28. if not hasattr(wx, 'IsMainThread'):
  29.     import threading
  30.     
  31.     def isMainThread():
  32.         return threading.currentThread().getName() == 'MainThread'
  33.  
  34.     wx.IsMainThread = isMainThread
  35.  
  36. wx.Rect.Clamp = new.instancemethod(cgui.RectClamp, None, wx.Rect)
  37. wx.Rect.ClampPoint = new.instancemethod(cgui.RectClampPoint, None, wx.Rect)
  38.  
  39. wx.ContextMenuEvent.IsKeyPress = lambda e: e.Position == (-1, -1)
  40.  
  41. wx.Timer.StartRepeating = lambda self, ms: wx.Timer.Start(self, ms, False)
  42.  
  43. wx.Timer.StartOneShot = lambda self, ms: wx.Timer.Start(self, ms, True)
  44.  
  45. def CreateTransparentBitmap(w, h):
  46.     bitmap = wx.EmptyBitmap(w, h)
  47.     bitmap.UseAlpha()
  48.     return bitmap
  49.  
  50. wx.TransparentBitmap = CreateTransparentBitmap
  51.  
  52. try:
  53.     from cgui import SetBold
  54. except ImportError:
  55.     import sys
  56.     print >>sys.stderr, 'WARNING: using slow SetBold'
  57.     
  58.     def SetBold(win, bold = True):
  59.         f = win.Font
  60.         None(f.SetWeight if bold else wx.FONTWEIGHT_NORMAL)
  61.         win.Font = f
  62.  
  63.  
  64. if getattr(wx, 'WXPY', False):
  65.     wx.WindowClass = wx._Window
  66. else:
  67.     wx.WindowClass = wx.Window
  68. wx.WindowClass.SetBold = new.instancemethod(SetBold, None, wx.WindowClass)
  69.  
  70. def call_later_repr(self):
  71.     funcinfo = funcinfo
  72.     import util
  73.     fi = funcinfo(self.callable)
  74.     if self.running:
  75.         return '<CallLater (running) %s>' % fi
  76.     return '<CallLater %s>' % fi
  77.  
  78. wx.CallLater.__repr__ = call_later_repr
  79.  
  80. def ReleaseAllCapture(ctrl):
  81.     while ctrl.HasCapture():
  82.         ctrl.ReleaseMouse()
  83.  
  84. wx.WindowClass.ReleaseAllCapture = ReleaseAllCapture
  85. if not getattr(wx, 'WXPY', False):
  86.     
  87.     wx.Dialog.__enter__ = lambda self: self
  88.     
  89.     wx.Dialog.__exit__ = lambda self, type, value, traceback: self.Destroy()
  90.     
  91.     def IsDestroyed(win):
  92.         return not bool(win)
  93.  
  94.     from cStringIO import StringIO
  95.     
  96.     def ImageFromString(s):
  97.         return wx.ImageFromStream(StringIO(s))
  98.  
  99.     wx.ImageFromString = ImageFromString
  100.     wx.AcceleratorTableFromSequence = wx.AcceleratorTable
  101.     wx.IsDestroyed = IsDestroyed
  102.     del IsDestroyed
  103.  
  104. if not hasattr(wx.RendererNative, 'DrawFocusRect'):
  105.     
  106.     wx.RendererNative.DrawFocusRect = lambda *a, **k: pass
  107.  
  108.  
  109. try:
  110.     import webview
  111. except ImportError:
  112.     traceback.print_exc()
  113.  
  114. if not hasattr(webview.WebView, 'ResetTextSize'):
  115.     
  116.     webview.WebView.ResetTextSize = lambda *a, **k: pass
  117.  
  118. if not hasattr(webview.WebView, 'SetMouseWheelZooms'):
  119.     
  120.     webview.WebView.SetMouseWheelZooms = lambda *a, **k: pass
  121.  
  122. if 'wxGTK' in wx.PlatformInfo:
  123.     orig_bmpeq = wx.Bitmap.__eq__
  124.     
  125.     def bmpeq(self, other):
  126.         if isinstance(other, wx.Bitmap):
  127.             return orig_bmpeq(self, other)
  128.         return False
  129.  
  130.     wx.Bitmap.__eq__ = bmpeq
  131.  
  132.  
  133. def RaiseExisting(cls):
  134.     for tlw in wx.GetTopLevelWindows():
  135.         if type(tlw) is cls:
  136.             tlw.Raise()
  137.             return tlw
  138.     
  139.  
  140. wx.TopLevelWindow.RaiseExisting = classmethod(RaiseExisting)
  141.  
  142. def MakeOrShow(cls, parent = None):
  143.     win = cls.RaiseExisting()
  144.     if win is None:
  145.         win = cls(parent)
  146.         wx.CallAfter(win.Show)
  147.     
  148.     return win
  149.  
  150. wx.TopLevelWindow.MakeOrShow = classmethod(MakeOrShow)
  151.  
  152. try:
  153.     from cgui import LeftDown
  154. except ImportError:
  155.     
  156.     def LeftDown():
  157.         return wx.GetMouseState().LeftDown()
  158.  
  159.  
  160. wx.LeftDown = LeftDown
  161. if not hasattr(wx.PyTimer, 'SetCallback'):
  162.     
  163.     def SetCallback(self, cb):
  164.         self.notify = cb
  165.  
  166.     wx.PyTimer.SetCallback = SetCallback
  167.  
  168.  
  169. def SetUserData(self, data):
  170.     self._userData = data
  171.  
  172.  
  173. def GetUserData(self):
  174.     return getattr(self, '_userData', None)
  175.  
  176. wx.SizerItem.SetUserData = SetUserData
  177. wx.SizerItem.GetUserData = GetUserData
  178.