home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 January / maximum-cd-2012-01.iso / DiscContents / digsby_setup.exe / lib / wx / __init__.pyo (.txt) next >
Encoding:
Python Compiled Bytecode  |  2011-10-05  |  33.8 KB  |  821 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import os.path as os
  5. import sys
  6. VERSION = (2, 8, 7, 1)
  7. USE_HTML = 0
  8. _wxpy_dir = os.path.split(os.path.abspath(__file__))[0]
  9. sys.path.append(_wxpy_dir)
  10. del _wxpy_dir
  11. if os.name == 'nt':
  12.     os.environ['PATH'] = os.pathsep.join([
  13.         os.path.abspath(os.path.join(os.path.split(__file__)[0], '..')),
  14.         os.environ['PATH']])
  15.  
  16. USE_UNICODE = True
  17. WXPY = True
  18. import sip
  19. import new
  20. from functools import wraps
  21.  
  22. class SipTrace(object):
  23.     VIRTUAL = 1
  24.     CONSTRUCTOR = 2
  25.     DESTRUCTOR = 4
  26.     PY_INIT = 8
  27.     PY_DEL = 16
  28.     PY_METHOD = 32
  29.  
  30. SipTrace.ALL = SipTrace.VIRTUAL | SipTrace.CONSTRUCTOR | SipTrace.DESTRUCTOR | SipTrace.PY_INIT | SipTrace.PY_DEL | SipTrace.PY_METHOD
  31. sip.settracemask(SipTrace.ALL)
  32.  
  33. def tracing(enable):
  34.     None(sip.settracemask if enable else 0)
  35.  
  36.  
  37. def autorepr(s = None):
  38.     if s is not None:
  39.         
  40.         def __repr__(self):
  41.             return '<%s %s>' % (self.__class__.__name__, s % vars(self))
  42.  
  43.     else:
  44.         
  45.         def __repr__(self):
  46.             return '<%s at %x>' % (self.__class__.__name__, id(self))
  47.  
  48.     return __repr__
  49.  
  50. from wx._wxcore import *
  51. import wx._wxcore as wx
  52. import sys as _sys
  53. from operator import attrgetter
  54.  
  55. def PyEventBinder(evttype, n = None):
  56.     return (evttype,)
  57.  
  58. _callafter = wx.CallAfter
  59. from traceback import print_exc
  60.  
  61. def CallAfter(func, *a, **k):
  62.     
  63.     def CallAfterCallback():
  64.         
  65.         try:
  66.             func(*a, **k)
  67.         except Exception:
  68.             print_exc()
  69.  
  70.  
  71.     return _callafter(CallAfterCallback)
  72.  
  73. wx.FrameNameStr = 'Frame'
  74. wx.DialogNameStr = 'Dialog'
  75. _MiniFrame = MiniFrame
  76.  
  77. class MiniFrame(_MiniFrame):
  78.     
  79.     def __init__(self, parent, id = -1, title = '', pos = DefaultPosition, size = DefaultSize, style = CAPTION | RESIZE_BORDER, name = 'frame'):
  80.         _MiniFrame.__init__(self, parent, id, title, pos, size, style, name)
  81.  
  82.  
  83. _Frame = wx.Frame
  84.  
  85. class Frame(_Frame):
  86.     
  87.     def __init__(self, parent, id = -1, title = '', pos = DefaultPosition, size = DefaultSize, style = DEFAULT_FRAME_STYLE, name = wx.FrameNameStr):
  88.         _Frame.__init__(self, parent, id, title, pos, size, style, name)
  89.  
  90.  
  91. _Frame.CentreOnScreen = new.instancemethod(_Frame.CenterOnScreen, None, _Frame)
  92. _Dialog = wx.Dialog
  93.  
  94. class Dialog(_Dialog):
  95.     
  96.     def __init__(self, parent, id = -1, title = '', pos = DefaultPosition, size = DefaultSize, style = DEFAULT_DIALOG_STYLE, name = wx.DialogNameStr):
  97.         _Dialog.__init__(self, parent, id, title, Point(*pos), Size(*size), style, name)
  98.  
  99.     
  100.     def __enter__(self):
  101.         return self
  102.  
  103.     
  104.     def __exit__(self, type, value, traceback):
  105.         self.Hide()
  106.         self.Destroy()
  107.  
  108.  
  109. _TextCtrl = wx.TextCtrl
  110.  
  111. class TextCtrl(_TextCtrl):
  112.     
  113.     def __init__(self, parent, id = -1, value = '', pos = DefaultPosition, size = DefaultSize, style = 0, validator = wx.DefaultValidator, name = 'text control'):
  114.         _TextCtrl.__init__(self, parent, id, value, pos, size, style, validator, name)
  115.  
  116.  
  117. _StaticText = wx.StaticText
  118.  
  119. class StaticText(_StaticText):
  120.     
  121.     def __init__(self, parent, id = -1, label = '', pos = DefaultPosition, size = DefaultSize, style = 0, name = 'static text'):
  122.         _StaticText.__init__(self, parent, id, label, pos, size, style, name)
  123.  
  124.  
  125. _StaticBox = wx.StaticBox
  126.  
  127. class StaticBox(_StaticBox):
  128.     
  129.     def __init__(self, parent, id, label, pos = DefaultPosition, size = DefaultSize, style = 0, name = 'staticBox'):
  130.         _StaticBox.__init__(self, parent, id, label, pos, size, style, name)
  131.  
  132.  
  133. _StaticBoxSizer = wx.StaticBoxSizer
  134.  
  135. class StaticBoxSizer(_StaticBoxSizer):
  136.     
  137.     def __init__(self, box, orient):
  138.         _StaticBoxSizer.__init__(self, box, orient)
  139.  
  140.  
  141. Font.init_args = init_args = ('pointSize', 'family', 'style', 'weight', 'underline', 'faceName', 'encoding')
  142. _Control = wx.Control
  143.  
  144. class Control(_Control):
  145.     
  146.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = 0, validator = wx.DefaultValidator, name = 'Control'):
  147.         _Control.__init__(self, parent, id, pos, size, style, validator, name)
  148.  
  149.  
  150. PyControl = Control
  151. _ToolTip = wx.ToolTip
  152. _Window = wx.Window
  153. _Window.SetToolTipString = new.instancemethod((lambda self, tip: self.SetToolTip(_ToolTip(tip))), None, _Window)
  154.  
  155. class Window(wx.Window):
  156.     
  157.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = 0, name = 'Window'):
  158.         _Window.__init__(self, parent, id, Point(*pos), Size(*size), style, name)
  159.  
  160.  
  161. _HyperlinkCtrl = wx.HyperlinkCtrl
  162.  
  163. class HyperlinkCtrl(wx.HyperlinkCtrl):
  164.     
  165.     def __init__(self, parent, id, label, url, pos = DefaultPosition, size = DefaultSize, style = HL_DEFAULT_STYLE, name = 'Hyperlink'):
  166.         _HyperlinkCtrl.__init__(self, parent, id, label, url, pos, size, style, name)
  167.  
  168.  
  169. _Panel = wx.Panel
  170.  
  171. class Panel(wx.Panel):
  172.     
  173.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = TAB_TRAVERSAL | NO_BORDER, name = 'Panel'):
  174.         _Panel.__init__(self, parent, id, Point(*pos), Size(*size), style, name)
  175.  
  176.  
  177. _MenuItem = wx.MenuItem
  178.  
  179. class MenuItem(wx.MenuItem):
  180.     
  181.     def __init__(self, parentMenu = None, id = ID_SEPARATOR, text = '', help = '', kind = wx.ITEM_NORMAL, subMenu = None):
  182.         _MenuItem.__init__(self, parentMenu, id, text, help, kind, subMenu)
  183.  
  184.  
  185. _VListBox = VListBox
  186.  
  187. class VListBox(_VListBox):
  188.     
  189.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = 0, name = 'VListBox'):
  190.         _VListBox.__init__(self, parent, id, pos, size, style, name)
  191.  
  192.     Selection = property(_VListBox.GetSelection, _VListBox.SetSelection)
  193.  
  194. _SearchCtrl = SearchCtrl
  195.  
  196. class SearchCtrl(_SearchCtrl):
  197.     
  198.     def __init__(self, parent, id = -1, value = '', pos = DefaultPosition, size = DefaultSize, style = 0, validator = DefaultValidator, name = 'SearchCtrl'):
  199.         _SearchCtrl.__init__(self, parent, id, value, pos, size, style, validator, name)
  200.  
  201.  
  202. _RadioButton = RadioButton
  203.  
  204. class RadioButton(_RadioButton):
  205.     
  206.     def __init__(self, parent, id = -1, label = '', pos = DefaultPosition, size = DefaultSize, style = 0, validator = DefaultValidator, name = 'RadioButton'):
  207.         _RadioButton.__init__(self, parent, id, label, pos, size, style, validator, name)
  208.  
  209.  
  210. _SplitterWindow = SplitterWindow
  211.  
  212. class SplitterWindow(_SplitterWindow):
  213.     
  214.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = wx.SP_3D, name = 'splitterWindow'):
  215.         _SplitterWindow.__init__(self, parent, id, pos, size, style, name)
  216.  
  217.  
  218. _ScrolledWindow = ScrolledWindow
  219.  
  220. class ScrolledWindow(_ScrolledWindow):
  221.     
  222.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = HSCROLL | VSCROLL, name = 'scrolledWindow'):
  223.         _ScrolledWindow.__init__(self, parent, id, pos, size, style, name)
  224.  
  225.  
  226. _Notebook = wx.Notebook
  227.  
  228. class Notebook(_Notebook):
  229.     
  230.     def __init__(self, parent, id = -1, pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, name = 'notebook'):
  231.         _Notebook.__init__(self, parent, id, pos, size, style, name)
  232.  
  233.  
  234. _TextEntryDialog = TextEntryDialog
  235.  
  236. class TextEntryDialog(_TextEntryDialog):
  237.     
  238.     def __init__(self, parent, message, caption = u'Input Text', defaultValue = '', style = TextEntryDialogStyle, pos = DefaultPosition):
  239.         _TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos)
  240.  
  241.  
  242. _CheckBox = CheckBox
  243.  
  244. class CheckBox(_CheckBox):
  245.     
  246.     def __init__(self, parent, id = ID_ANY, label = '', pos = DefaultPosition, size = DefaultSize, style = 0, validator = DefaultValidator, name = 'checkBox'):
  247.         _CheckBox.__init__(self, parent, id, label, pos, size, style, validator, name)
  248.  
  249.  
  250. _Choice = Choice
  251.  
  252. class Choice(_Choice):
  253.     
  254.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, choices = None, style = 0, validator = DefaultValidator, name = 'choice'):
  255.         None(_Choice.__init__, self, parent, id, pos, size if choices is not None else [], style, validator, name)
  256.  
  257.  
  258. _Slider = Slider
  259.  
  260. class Slider(_Slider):
  261.     
  262.     def __init__(self, parent, id = -1, value = 0, minValue = 0, maxValue = 100, pos = DefaultPosition, size = DefaultSize, style = SL_HORIZONTAL, validator = DefaultValidator, name = 'slider'):
  263.         _Slider.__init__(self, parent, id, value, minValue, maxValue, pos, size, style, validator, name)
  264.  
  265.  
  266. _BoxSizer = BoxSizer
  267.  
  268. class BoxSizer(_BoxSizer):
  269.     
  270.     def __init__(self, orient):
  271.         _BoxSizer.__init__(self, orient)
  272.  
  273.  
  274. _GridBagSizer = GridBagSizer
  275.  
  276. class GridBagSizer(_GridBagSizer):
  277.     
  278.     def __init__(self, vgap = 0, hgap = 0):
  279.         _GridBagSizer.__init__(self, vgap, hgap)
  280.  
  281.  
  282. _GridSizer = GridSizer
  283.  
  284. class GridSizer(_GridSizer):
  285.     
  286.     def __init__(self, rows = 1, cols = 0, vgap = 0, hgap = 0):
  287.         _GridSizer.__init__(self, rows, cols, vgap, hgap)
  288.  
  289.  
  290. _FlexGridSizer = FlexGridSizer
  291.  
  292. class FlexGridSizer(_FlexGridSizer):
  293.     
  294.     def __init__(self, rows = 1, cols = 0, vgap = 0, hgap = 0):
  295.         _FlexGridSizer.__init__(self, rows, cols, vgap, hgap)
  296.  
  297.  
  298. _Gauge = Gauge
  299.  
  300. class Gauge(_Gauge):
  301.     
  302.     def __init__(self, parent, id = -1, range = 100, pos = DefaultPosition, size = DefaultSize, style = GA_HORIZONTAL, validator = DefaultValidator, name = 'gauge'):
  303.         _Gauge.__init__(self, parent, id, range, pos, size, style, validator, name)
  304.  
  305.  
  306. _StaticLine = StaticLine
  307.  
  308. class StaticLine(_StaticLine):
  309.     
  310.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = LI_HORIZONTAL, name = 'static line'):
  311.         _StaticLine.__init__(self, parent, id, pos, size, style, name)
  312.  
  313.  
  314. wxDIRP_DEFAULT_STYLE = DIRP_DEFAULT_STYLE
  315. _DirPickerCtrl = DirPickerCtrl
  316.  
  317. class DirPickerCtrl(_DirPickerCtrl):
  318.     
  319.     def __init__(self, parent, id = -1, path = '', message = 'Select a folder', pos = DefaultPosition, size = DefaultSize, style = wxDIRP_DEFAULT_STYLE, validator = DefaultValidator, name = 'dirpicker'):
  320.         _DirPickerCtrl.__init__(self, parent, id, path, message, pos, size, style, validator, name)
  321.  
  322.  
  323. wxFLP_DEFAULT_STYLE = FLP_DEFAULT_STYLE
  324. _FilePickerCtrl = FilePickerCtrl
  325.  
  326. class FilePickerCtrl(_FilePickerCtrl):
  327.     
  328.     def __init__(self, parent, id = -1, path = '', message = 'Select a file', wildcard = '*.*', pos = DefaultPosition, size = DefaultSize, style = wxFLP_DEFAULT_STYLE, validator = DefaultValidator, name = 'filepicker'):
  329.         _FilePickerCtrl.__init__(self, parent, id, path, message, wildcard, pos, size, style, validator, name)
  330.  
  331.  
  332. _FileSelector = FileSelector
  333.  
  334. def FileSelector(message = 'Choose a file', default_path = '', default_filename = '', default_extension = '', wildcard = '*.*', flags = 0, parent = None, x = -1, y = -1):
  335.     return _FileSelector(message, default_path, default_filename, default_extension, wildcard, flags, parent, x, y)
  336.  
  337. _FileDialog = FileDialog
  338.  
  339. class FileDialog(_FileDialog):
  340.     
  341.     def __init__(self, parent, message = 'Select a file', defaultDir = '', defaultFile = '', wildcard = '*.*', style = FD_DEFAULT_STYLE, pos = DefaultPosition):
  342.         _FileDialog.__init__(self, parent, message, defaultDir, defaultFile, wildcard, style, pos)
  343.  
  344.  
  345. _ComboBox = ComboBox
  346.  
  347. class ComboBox(_ComboBox):
  348.     
  349.     def __init__(self, parent, id, value = '', pos = DefaultPosition, size = DefaultSize, choices = None, style = 0, validator = DefaultValidator, name = 'comboBox'):
  350.         None(_ComboBox.__init__, self, parent, id, value, pos, size if choices is None else choices, style, validator, name)
  351.  
  352.  
  353. _CustomDataObject = CustomDataObject
  354.  
  355. class CustomDataObject(_CustomDataObject):
  356.     
  357.     def __init__(self, obj):
  358.         if isinstance(obj, basestring):
  359.             return _CustomDataObject.__init__(self, CustomDataFormat(obj))
  360.         return _CustomDataObject.__init__(self, obj)
  361.  
  362.  
  363. _ListCtrl = ListCtrl
  364.  
  365. class ListCtrl(_ListCtrl):
  366.     
  367.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = LC_ICON, validator = DefaultValidator, name = 'listCtrl'):
  368.         _ListCtrl.__init__(self, parent, id, pos, size, style, validator, name)
  369.  
  370.     
  371.     def Select(self, idx, on = 1):
  372.         if on:
  373.             state = LIST_STATE_SELECTED
  374.         else:
  375.             state = 0
  376.         self.SetItemState(idx, state, LIST_STATE_SELECTED)
  377.  
  378.     
  379.     def Focus(self, idx):
  380.         self.SetItemState(idx, LIST_STATE_FOCUSED, LIST_STATE_FOCUSED)
  381.         self.EnsureVisible(idx)
  382.  
  383.     
  384.     def GetFocusedItem(self):
  385.         return self.GetNextItem(-1, LIST_NEXT_ALL, LIST_STATE_FOCUSED)
  386.  
  387.     
  388.     def GetFirstSelected(self, *args):
  389.         return self.GetNextSelected(-1)
  390.  
  391.     
  392.     def GetNextSelected(self, item):
  393.         return self.GetNextItem(item, LIST_NEXT_ALL, LIST_STATE_SELECTED)
  394.  
  395.     
  396.     def IsSelected(self, idx):
  397.         return self.GetItemState(idx, LIST_STATE_SELECTED) & LIST_STATE_SELECTED != 0
  398.  
  399.     
  400.     def SetColumnImage(self, col, image):
  401.         item = self.GetColumn(col)
  402.         item.SetMask(LIST_MASK_STATE | LIST_MASK_TEXT | LIST_MASK_IMAGE | LIST_MASK_DATA | LIST_SET_ITEM | LIST_MASK_WIDTH | LIST_MASK_FORMAT)
  403.         item.SetImage(image)
  404.         self.SetColumn(col, item)
  405.  
  406.     
  407.     def ClearColumnImage(self, col):
  408.         self.SetColumnImage(col, -1)
  409.  
  410.     
  411.     def Append(self, entry):
  412.         if len(entry):
  413.             if USE_UNICODE:
  414.                 cvtfunc = unicode
  415.             else:
  416.                 cvtfunc = str
  417.             pos = self.GetItemCount()
  418.             self.InsertStringItem(pos, cvtfunc(entry[0]))
  419.             for i in range(1, len(entry)):
  420.                 self.SetStringItem(pos, i, cvtfunc(entry[i]))
  421.             
  422.             return pos
  423.  
  424.  
  425.  
  426. ItemContainer.GetItems = lambda self: [ self.GetString(i) for i in xrange(self.GetCount()) ]
  427.  
  428. def SetItems(self, items):
  429.     self.Clear()
  430.     for item in items:
  431.         self.Append(item)
  432.     
  433.  
  434. ItemContainer.SetItems = SetItems
  435. del SetItems
  436. ItemContainer.Items = property(ItemContainer.GetItems, ItemContainer.SetItems)
  437. _Button = wx.Button
  438.  
  439. class Button(wx.Button):
  440.     
  441.     def __init__(self, parent, id = -1, label = '', pos = DefaultPosition, size = DefaultSize, style = 0, validator = DefaultValidator, name = 'button'):
  442.         _Button.__init__(self, parent, id, label, pos, size, style, validator, name)
  443.  
  444.  
  445. _PopupTransientWindow = wx.PopupTransientWindow
  446.  
  447. class PopupTransientWindow(_PopupTransientWindow):
  448.     
  449.     def __init__(self, window, style = BORDER_NONE):
  450.         _PopupTransientWindow.__init__(self, window, style)
  451.  
  452.  
  453. _FileConfig = wx.FileConfig
  454.  
  455. class FileConfig(_FileConfig):
  456.     
  457.     def __init__(self, appName = '', vendorName = '', localFilename = '', globalFilename = '', style = CONFIG_USE_LOCAL_FILE | CONFIG_USE_GLOBAL_FILE):
  458.         _FileConfig.__init__(self, appName, vendorName, localFilename, globalFilename, style)
  459.  
  460.  
  461. _PyWindow = wx.PyWindow
  462.  
  463. class PyWindow(_PyWindow):
  464.     
  465.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = 0, name = 'panel'):
  466.         _PyWindow.__init__(self, parent, id, pos, size, style, name)
  467.  
  468.  
  469. _PyPanel = wx.PyPanel
  470.  
  471. class PyPanel(_PyPanel):
  472.     
  473.     def __init__(self, parent, id = -1, pos = DefaultPosition, size = DefaultSize, style = TAB_TRAVERSAL | NO_BORDER, name = 'panel'):
  474.         _PyPanel.__init__(self, parent, id, pos, size, style, name)
  475.  
  476.  
  477.  
  478. def _set_sizer_deleted(win):
  479.     old_sizer = win.Sizer
  480.     if old_sizer is not None:
  481.         sip.setdeleted(old_sizer)
  482.     
  483.  
  484. _window_setsizer = Window.SetSizer
  485.  
  486. def _Window_SetSizer(self, sizer, deleteOld = True):
  487.     if deleteOld:
  488.         _set_sizer_deleted(self)
  489.     
  490.     return _window_setsizer(self, sizer, deleteOld)
  491.  
  492. _window_setsizerandfit = Window.SetSizerAndFit
  493.  
  494. def _Window_SetSizerAndFit(self, sizer, deleteOld = True):
  495.     if deleteOld:
  496.         _set_sizer_deleted(self)
  497.     
  498.     return _window_setsizerandfit(self, sizer, deleteOld)
  499.  
  500. DefaultSpan = (1, 1)
  501. _gbsizer_add = GridBagSizer.Add
  502.  
  503. def GridBagSizer_Add(self, item, pos = DefaultPosition, span = DefaultSpan, flag = 0, border = 0):
  504.     if isinstance(item, Size):
  505.         item = tuple(item)
  506.     
  507.     return _gbsizer_add(self, item, pos, span, flag, border)
  508.  
  509. GridBagSizer.Add = GridBagSizer_Add
  510. del GridBagSizer_Add
  511. _sizer_add = Sizer.Add
  512.  
  513. def Sizer_Add(self, item, proportion = 0, flag = 0, border = 0):
  514.     if item is None:
  515.         raise TypeError
  516.     item is None
  517.     if isinstance(item, _Window):
  518.         containing_sizer = item.ContainingSizer
  519.         if containing_sizer is not None and containing_sizer != self:
  520.             raise Exception('attempting to add window %r but it is already added to sizer %r' % (item, containing_sizer))
  521.         containing_sizer != self
  522.     
  523.     
  524.     try:
  525.         return _sizer_add(self, item, proportion, flag, border)
  526.     except TypeError:
  527.         if isinstance(item, WindowBase):
  528.             return _sizer_add(self, WindowBaseDowncast(item), proportion, flag, border)
  529.     except:
  530.         isinstance(item, WindowBase)
  531.  
  532.  
  533. Sizer.Add = Sizer_Add
  534. del Sizer_Add
  535. _sizer_clear = Sizer.Clear
  536.  
  537. def Sizer_Clear(self, deleteWindows = False):
  538.     return _sizer_clear(self, deleteWindows)
  539.  
  540. Sizer.Clear = Sizer_Clear
  541. del Sizer_Clear
  542.  
  543. def Sizer_AddMany(self, seq):
  544.     for item in seq:
  545.         if (type(item) != type(()) or len(item) == 2) and type(item[0]) == type(1):
  546.             item = (item,)
  547.         
  548.         
  549.         try:
  550.             self.Add(*item)
  551.         continue
  552.         except Exception:
  553.             print >>_sys.stderr, 'Bad item:', item
  554.             raise 
  555.             continue
  556.         
  557.  
  558.     
  559.  
  560. Sizer.AddMany = Sizer_AddMany
  561. _evthandler_bind = EvtHandler.Bind
  562.  
  563. def EvtHandler_Bind(self, event, func, source = None, id = wx.ID_ANY, id2 = wx.ID_ANY):
  564.     return _evthandler_bind(self, event, func, source, id, id2)
  565.  
  566. EvtHandler.Bind = EvtHandler_Bind
  567. del EvtHandler_Bind
  568. _notebook_addpage = Notebook.AddPage
  569.  
  570. def Notebook_AddPage(self, page, text, select = False, imageId = -1):
  571.     return _notebook_addpage(self, page, text, select, imageId)
  572.  
  573. Notebook_AddPage = wraps(_notebook_addpage)(Notebook_AddPage)
  574. Notebook.AddPage = Notebook_AddPage
  575. del Notebook_AddPage
  576. Size.width = property(attrgetter('x'), (lambda s, val: setattr(s, 'x', val)))
  577. Size.height = property(attrgetter('y'), (lambda s, val: setattr(s, 'y', val)))
  578. Rect.left = property(Rect.GetX, Rect.SetX)
  579. Rect.top = property(Rect.GetY, Rect.SetY)
  580. Rect.bottom = property(Rect.GetBottom, Rect.SetBottom)
  581. Rect.right = property(Rect.GetRight, Rect.SetRight)
  582. _dc_drawlabel = DC.DrawLabel
  583.  
  584. def DC_DrawLabel(self, text, rect, alignment = ALIGN_LEFT | ALIGN_TOP, indexAccel = -1):
  585.     return _dc_drawlabel(self, text, rect, alignment, indexAccel)
  586.  
  587. DC.DrawLabel = DC_DrawLabel
  588. del DC_DrawLabel
  589.  
  590. def MenuBar_GetMenus(self):
  591.     return [ (self.GetMenu(i), self.GetLabelTop(i)) for i in range(self.GetMenuCount()) ]
  592.  
  593.  
  594. def MenuBar_SetMenus(self, items):
  595.     for i in range(self.GetMenuCount() - 1, -1, -1):
  596.         self.Remove(i)
  597.     
  598.     for m, l in items:
  599.         self.Append(m, l)
  600.     
  601.  
  602. MenuBar.GetMenus = MenuBar_GetMenus
  603. MenuBar.SetMenus = MenuBar_SetMenus
  604. MenuBar.Menus = property(MenuBar_GetMenus, MenuBar_SetMenus)
  605. _MessageBox = MessageBox
  606.  
  607. def MessageBox(message, caption = 'Message', style = OK, parent = None, x = -1, y = -1):
  608.     return _MessageBox(message, caption, style, parent, x, y)
  609.  
  610. WXK_PRIOR = wx.WXK_PAGEUP
  611. WXK_NEXT = wx.WXK_PAGEDOWN
  612.  
  613. class PyTimer(Timer):
  614.     
  615.     def __init__(self, notify):
  616.         Timer.__init__(self)
  617.         self._pytimer_notify_callback = notify
  618.  
  619.     
  620.     def SetCallback(self, cb):
  621.         self._pytimer_notify_callback = cb
  622.  
  623.     
  624.     def Notify(self):
  625.         notify = getattr(self, '_pytimer_notify_callback', None)
  626.         if notify is not None:
  627.             notify()
  628.         
  629.  
  630.  
  631.  
  632. class CallLater(object):
  633.     
  634.     def __init__(self, millis, cb, *args, **kwargs):
  635.         self.millis = millis
  636.         self.callable = cb
  637.         self.SetArgs(*args, **kwargs)
  638.         self.runCount = 0
  639.         self.running = False
  640.         self.hasRun = False
  641.         self.result = None
  642.         self.timer = None
  643.         CallAfter(self.Start)
  644.  
  645.     
  646.     def Start(self, millis = None, *args, **kwargs):
  647.         self.hasRun = False
  648.         if millis is not None:
  649.             self.millis = millis
  650.         
  651.         if args or kwargs:
  652.             self.SetArgs(*args, **kwargs)
  653.         
  654.         self.Stop()
  655.         self.timer = PyTimer(self.Notify)
  656.         self.timer.Start(self.millis, TIMER_ONE_SHOT)
  657.         self.running = True
  658.         import wx
  659.         
  660.         try:
  661.             timers = wx.GetApp()._calllater_timers
  662.         except AttributeError:
  663.             timers = wx.GetApp()._calllater_timers = set()
  664.  
  665.         timers.add(self)
  666.  
  667.     Restart = Start
  668.     
  669.     def Stop(self):
  670.         if self.timer is not None:
  671.             self.timer.Stop()
  672.             self.timer = None
  673.             timers = GetApp()._calllater_timers
  674.             timers.discard(self)
  675.         
  676.  
  677.     
  678.     def GetInterval(self):
  679.         if self.timer is not None:
  680.             return self.timer.GetInterval()
  681.         return 0
  682.  
  683.     
  684.     def IsRunning(self):
  685.         if self.timer is not None:
  686.             pass
  687.         return self.timer.IsRunning()
  688.  
  689.     
  690.     def SetArgs(self, *args, **kwargs):
  691.         self.args = args
  692.         self.kwargs = kwargs
  693.  
  694.     
  695.     def HasRun(self):
  696.         return self.hasRun
  697.  
  698.     
  699.     def GetResult(self):
  700.         return self.result
  701.  
  702.     
  703.     def Notify(self):
  704.         if self.callable and getattr(self.callable, 'im_self', True):
  705.             self.runCount += 1
  706.             self.running = False
  707.             self.result = self.callable(*self.args, **self.kwargs)
  708.         
  709.         self.hasRun = True
  710.         if not self.running:
  711.             CallAfter(self.Stop)
  712.         
  713.  
  714.     Interval = property(GetInterval)
  715.     Result = property(GetResult)
  716.  
  717. PyDeadObjectError = sip.DeadObjectException
  718. _app = wx.PyApp
  719. _entrystart = wx.EntryStart
  720. _initallimagehandlers = wx.InitAllImageHandlers
  721. _getapp = wx.GetApp
  722. _init_gdi_constants = wx._init_gdi_constants
  723.  
  724. def _wxpy_init(clearSigInt = True):
  725.     if clearSigInt:
  726.         
  727.         try:
  728.             import signal
  729.             signal.signal(signal.SIGINT, signal.SIG_DFL)
  730.         except Exception:
  731.             pass
  732.         except:
  733.             None<EXCEPTION MATCH>Exception
  734.         
  735.  
  736.     None<EXCEPTION MATCH>Exception
  737.     if USE_HTML:
  738.         
  739.         try:
  740.             import lib.wxpTag as lib
  741.         except Exception:
  742.             print_exc = print_exc
  743.             import traceback
  744.             print_exc()
  745.         except:
  746.             None<EXCEPTION MATCH>Exception
  747.         
  748.  
  749.     None<EXCEPTION MATCH>Exception
  750.     _entrystart()
  751.     _initallimagehandlers()
  752.     _init_gdi_constants()
  753.  
  754. _did_wxpy_init = False
  755.  
  756. class App(_app):
  757.     
  758.     def __init__(self, redirect = False, filename = None, useBestVisual = False, clearSigInt = True):
  759.         global _did_wxpy_init
  760.         _app.__init__(self)
  761.         if not _did_wxpy_init:
  762.             _wxpy_init(clearSigInt)
  763.             _did_wxpy_init = True
  764.         
  765.         self.SetExitOnFrameDelete(True)
  766.         self.OnInit()
  767.  
  768.  
  769. PySimpleApp = App
  770. wxEVT_ACTIVATE = wx.EVT_ACTIVATE
  771. wxEVT_KEY_DOWN = wx.EVT_KEY_DOWN
  772. wxEVT_SIZE = wx.EVT_SIZE
  773. wxEVT_CHAR = wx.EVT_CHAR
  774. wxEVT_MENU_CLOSE = wx.EVT_MENU_CLOSE
  775. wxEVT_MENU_OPEN = wx.EVT_MENU_OPEN
  776. wxEVT_COMMAND_MENU_SELECTED = wx.EVT_COMMAND_MENU_SELECTED
  777. wxEVT_MOUSE_CAPTURE_LOST = wx.EVT_MOUSE_CAPTURE_LOST
  778. wxEVT_MOTION = wx.EVT_MOTION
  779. wxEVT_COMMAND_BUTTON_CLICKED = wx.EVT_COMMAND_BUTTON_CLICKED
  780. wxEVT_COMMAND_LIST_ITEM_FOCUSED = EVT_COMMAND_LIST_ITEM_FOCUSED
  781. wxEVT_COMMAND_LIST_ITEM_SELECTED = EVT_COMMAND_LIST_ITEM_SELECTED
  782. wxEVT_COMMAND_LIST_ITEM_DESELECTED = EVT_COMMAND_LIST_ITEM_DESELECTED
  783. wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = EVT_COMMAND_LISTBOX_DOUBLECLICKED
  784. wxEVT_COMMAND_LISTBOX_SELECTED = EVT_COMMAND_LISTBOX_SELECTED
  785. wxEVT_COMMAND_CHECKBOX_CLICKED = EVT_COMMAND_CHECKBOX_CLICKED
  786. wxEVT_COMMAND_TOGGLEBUTTON_CLICKED = EVT_COMMAND_TOGGLEBUTTON_CLICKED
  787. CYAN_BRUSH = Brush(Colour(32, 178, 170))
  788. EVT_SPLITTER_DCLICK = EVT_SPLITTER_DOUBLECLICKED
  789. FindWindowByName = wx.Window.FindWindowByName
  790. Color = wx.Colour
  791. NamedColor = wx.NamedColour
  792. PyBitmapDataObject = wx.BitmapDataObject
  793. PyDropTarget = wx.DropTarget
  794. PyValidator = wx.Validator
  795. CommandEvent.Checked = property(CommandEvent.IsChecked)
  796. PyCommandEvent = wx.CommandEvent
  797. PyScrolledWindow = ScrolledWindow
  798. SystemSettings_GetColour = wx.SystemSettings.GetColour
  799. _Window.LayoutDirection = property(_Window.GetLayoutDirection, _Window.SetLayoutDirection)
  800. wx.Window.Enabled = property(wx.Window.IsEnabled, wx.Window.Enable)
  801. wx.Window.TopLevel = property(wx.Window.IsTopLevel)
  802.  
  803. BusyCursor = lambda : 'WXPYHACK'
  804.  
  805. BeginBusyCursor = lambda : 'WXPYHACK'
  806.  
  807. EndBusyCursor = lambda : 'WXPYHACK'
  808.  
  809. GetDefaultPyEncoding = lambda : 'utf-8'
  810. TreeItemData = PyTreeItemData
  811. FutureCall = CallLater
  812. _AxBaseWindow = AxBaseWindow
  813.  
  814. def IsDestroyed(win):
  815.     if win is None:
  816.         raise ValueError('IsDestroyed does not take None')
  817.     win is None
  818.     return sip.isdeleted(win)
  819.  
  820. del wx
  821.