home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / wx / __init__.pyo (.txt) next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  33.2 KB  |  804 lines

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