except:
pass
def _setCallbackInfo(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp__setCallbackInfo,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp__setCallbackInfo(self, *_args, **_kwargs)
return val
def GetAppName(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetAppName,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetAppName(self, *_args, **_kwargs)
return val
def GetClassName(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetClassName,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetClassName(self, *_args, **_kwargs)
return val
def GetExitOnFrameDelete(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetExitOnFrameDelete,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetExitOnFrameDelete(self, *_args, **_kwargs)
return val
def GetPrintMode(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetPrintMode,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetPrintMode(self, *_args, **_kwargs)
return val
def GetTopWindow(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetTopWindow,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetTopWindow(self, *_args, **_kwargs)
return val
def GetVendorName(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetVendorName,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetVendorName(self, *_args, **_kwargs)
return val
def GetUseBestVisual(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetUseBestVisual,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetUseBestVisual(self, *_args, **_kwargs)
return val
def Dispatch(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_Dispatch,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_Dispatch(self, *_args, **_kwargs)
return val
def ExitMainLoop(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_ExitMainLoop,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_ExitMainLoop(self, *_args, **_kwargs)
return val
def Initialized(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_Initialized,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_Initialized(self, *_args, **_kwargs)
return val
def MainLoop(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_MainLoop,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_MainLoop(self, *_args, **_kwargs)
return val
def Pending(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_Pending,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_Pending(self, *_args, **_kwargs)
return val
def ProcessIdle(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_ProcessIdle,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_ProcessIdle(self, *_args, **_kwargs)
return val
def Yield(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_Yield,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_Yield(self, *_args, **_kwargs)
return val
def SetAppName(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetAppName,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetAppName(self, *_args, **_kwargs)
return val
def SetClassName(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetClassName,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetClassName(self, *_args, **_kwargs)
return val
def SetExitOnFrameDelete(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetExitOnFrameDelete,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetExitOnFrameDelete(self, *_args, **_kwargs)
return val
def SetPrintMode(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetPrintMode,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetPrintMode(self, *_args, **_kwargs)
return val
def SetTopWindow(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetTopWindow,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetTopWindow(self, *_args, **_kwargs)
return val
def SetVendorName(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetVendorName,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetVendorName(self, *_args, **_kwargs)
return val
def SetUseBestVisual(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetUseBestVisual,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetUseBestVisual(self, *_args, **_kwargs)
return val
def GetAssertMode(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_GetAssertMode,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_GetAssertMode(self, *_args, **_kwargs)
return val
def SetAssertMode(self, *_args, **_kwargs):
- val = apply(wxc.wxPyApp_SetAssertMode,(self,) + _args, _kwargs)
+ val = wxc.wxPyApp_SetAssertMode(self, *_args, **_kwargs)
return val
def __repr__(self):
- return "<C wxPyApp instance at %s>" % (self.this,)
+ return "<%s.%s instance; proxy of C++ wxPyApp instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this)
class wxPyApp(wxPyAppPtr):
def __init__(self,*_args,**_kwargs):
- self.this = apply(wxc.new_wxPyApp,_args,_kwargs)
+ self.this = wxc.new_wxPyApp(*_args,**_kwargs)
self.thisown = 1
self._setCallbackInfo(self, wxPyApp)
self._setOORInfo(self)
_wxSetDictionary = wxc._wxSetDictionary
def wxGetApp(*_args, **_kwargs):
- val = apply(wxc.wxGetApp,_args,_kwargs)
+ val = wxc.wxGetApp(*_args,**_kwargs)
return val
wxApp_CleanUp = wxc.wxApp_CleanUp
wxFRAME_FLOAT_ON_PARENT = wxc.wxFRAME_FLOAT_ON_PARENT
wxFRAME_NO_WINDOW_MENU = wxc.wxFRAME_NO_WINDOW_MENU
wxFRAME_NO_TASKBAR = wxc.wxFRAME_NO_TASKBAR
+wxFRAME_SHAPED = wxc.wxFRAME_SHAPED
wxED_CLIENT_MARGIN = wxc.wxED_CLIENT_MARGIN
wxED_BUTTONS_BOTTOM = wxc.wxED_BUTTONS_BOTTOM
wxED_BUTTONS_RIGHT = wxc.wxED_BUTTONS_RIGHT
wxGROW = wxc.wxGROW
wxEXPAND = wxc.wxEXPAND
wxNB_FIXEDWIDTH = wxc.wxNB_FIXEDWIDTH
+wxNB_TOP = wxc.wxNB_TOP
wxNB_LEFT = wxc.wxNB_LEFT
wxNB_RIGHT = wxc.wxNB_RIGHT
wxNB_BOTTOM = wxc.wxNB_BOTTOM
wxEVT_COMMAND_ENTER = wxc.wxEVT_COMMAND_ENTER
wxEVT_NAVIGATION_KEY = wxc.wxEVT_NAVIGATION_KEY
wxEVT_TIMER = wxc.wxEVT_TIMER
-__version__ = wxc.__version__
cvar = wxc.cvar
wxDefaultPosition = wxPointPtr(wxc.cvar.wxDefaultPosition)
wxDefaultSize = wxSizePtr(wxc.cvar.wxDefaultSize)
win.Connect(id1, id2, wxEVT_SASH_DRAGGED, func)
def EVT_QUERY_LAYOUT_INFO(win, func):
- win.Connect(-1, -1, wxEVT_EVT_QUERY_LAYOUT_INFO, func)
+ win.Connect(-1, -1, wxEVT_QUERY_LAYOUT_INFO, func)
def EVT_CALCULATE_LAYOUT(win, func):
- win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func)
+ win.Connect(-1, -1, wxEVT_CALCULATE_LAYOUT, func)
#wxSplitterWindow
# workarounds for bad wxRTTI names
__wxPyPtrTypeMap['wxGauge95'] = 'wxGauge'
+__wxPyPtrTypeMap['wxSlider95'] = 'wxSlider'
+__wxPyPtrTypeMap['wxStatusBar95'] = 'wxStatusBar'
except:
pass
+# On MSW add the directory where the wxWindows catalogs were installed
+# to the default catalog path.
if wxPlatform == "__WXMSW__":
import os
localedir = os.path.join(os.path.split(__file__)[0], "locale")
del os
#----------------------------------------------------------------------
-# wxWindows version numbers. wxPython version is in __version__.
+# Load version numbers from __version__... Ensure that major and minor
+# versions are the same for both wxPython and wxWindows.
-wxMAJOR_VERSION = wxc.wxMAJOR_VERSION
-wxMINOR_VERSION = wxc.wxMINOR_VERSION
-wxRELEASE_NUMBER = wxc.wxRELEASE_NUMBER
-wxVERSION_STRING = wxc.wxVERSION_STRING
-wxVERSION_NUMBER = wxc.wxVERSION_NUMBER
+from wxPython.__version__ import *
+__version__ = wxVERSION_STRING
-wxVERSION = (wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER)
+assert wxMAJOR_VERSION == wxc.wxMAJOR_VERSION, "wxPython/wxWindows version mismatch"
+assert wxMINOR_VERSION == wxc.wxMINOR_VERSION, "wxPython/wxWindows version mismatch"
+if wxRELEASE_VERSION != wxc.wxRELEASE_VERSION:
+ import warnings
+ warnings.warn("wxPython/wxWindows release number mismatch")
#----------------------------------------------------------------------
global _wxCallAfterId
if _wxCallAfterId is None:
- _wxCallAfterId = wxNewId()
+ _wxCallAfterId = wxNewEventType()
app.Connect(-1, -1, _wxCallAfterId,
- lambda event: apply(event.callable, event.args, event.kw) )
+ lambda event: event.callable(*event.args, **event.kw) )
evt = wxPyEvent()
evt.SetEventType(_wxCallAfterId)
evt.callable = callable
evt.kw = kw
wxPostEvent(app, evt)
-# an alias
-wxRunLater = wxCallAfter
+
+#----------------------------------------------------------------------
+
+
+class wxFutureCall:
+ """
+ A convenience class for wxTimer, that calls the given callable
+ object once after the given amount of milliseconds, passing any
+ positional or keyword args. The return value of the callable is
+ availbale after it has been run with the GetResult method.
+
+ If you don't need to get the return value or restart the timer
+ then there is no need to hold a reference to this object. It will
+ hold a reference to itself while the timer is running (the timer
+ has a reference to self.Notify) but the cycle will be broken when
+ the timer completes, automatically cleaning up the wxFutureCall
+ object.
+ """
+ def __init__(self, millis, callable, *args, **kwargs):
+ self.millis = millis
+ self.callable = callable
+ self.SetArgs(*args, **kwargs)
+ self.runCount = 0
+ self.hasRun = False
+ self.result = None
+ self.timer = None
+ self.Start()
+
+ def __del__(self):
+ self.Stop()
+
+
+ def Start(self, millis=None):
+ """
+ (Re)start the timer
+ """
+ self.hasRun = False
+ if millis is not None:
+ self.millis = millis
+ self.Stop()
+ self.timer = wxPyTimer(self.Notify)
+ self.timer.Start(self.millis, wxTIMER_ONE_SHOT)
+ Restart = Start
+
+
+ def Stop(self):
+ """
+ Stop and destroy the timer.
+ """
+ if self.timer is not None:
+ self.timer.Stop()
+ self.timer = None
+
+
+ def GetInterval(self):
+ if self.timer is not None:
+ return self.timer.GetInterval()
+ else:
+ return 0
+
+
+ def IsRunning(self):
+ return self.timer is not None and self.timer.IsRunning()
+
+
+ def SetArgs(self, *args, **kwargs):
+ """
+ (Re)set the args passed to the callable object. This is
+ useful in conjunction with Restart if you want to schedule a
+ new call to the same callable object but with different
+ parameters.
+ """
+ self.args = args
+ self.kwargs = kwargs
+
+ def HasRun(self):
+ return self.hasRun
+
+ def GetResult(self):
+ return self.result
+
+ def Notify(self):
+ """
+ The timer has expired so call the callable.
+ """
+ if self.callable and getattr(self.callable, 'im_self', True):
+ self.runCount += 1
+ self.result = self.callable(*self.args, **self.kwargs)
+ self.hasRun = True
+ wxCallAfter(self.Stop)
+
#----------------------------------------------------------------------
return 0
+#----------------------------------------------------------------------
+
+class wxNotebookPage(wxPanel):
+ """
+ There is an old (and apparently unsolvable) bug when placing a
+ window with a nonstandard background colour in a wxNotebook on
+ wxGTK, as the notbooks's background colour would always be used
+ when the window is refreshed. The solution is to place a panel in
+ the notbook and the coloured window on the panel, sized to cover
+ the panel. This simple class does that for you, just put an
+ instance of this in the notebook and make your regular window a
+ child of this one and it will handle the resize for you.
+ """
+ def __init__(self, parent, id=-1,
+ pos=wxDefaultPosition, size=wxDefaultSize,
+ style=wxTAB_TRAVERSAL, name="panel"):
+ wxPanel.__init__(self, parent, id, pos, size, style, name)
+ self.child = None
+ EVT_SIZE(self, self.OnSize)
+ def OnSize(self, evt):
+ if self.child is None:
+ children = self.GetChildren()
+ if len(children):
+ self.child = children[0]
+ if self.child:
+ self.child.SetPosition((0,0))
+ self.child.SetSize(self.GetSize())
+
+
#----------------------------------------------------------------------
#----------------------------------------------------------------------
def __init__(self, redirect=_defRedirect, filename=None, useBestVisual=False):
wxPyApp.__init__(self)
+
+ if wx.wxPlatform == "__WXMAC__":
+ try:
+ import MacOS
+ if not MacOS.WMAvailable():
+ print """This program needs access to the screen. Please run with
+'pythonw', not 'python', and only when you are logged in on the main display
+of your Mac."""
+ sys.exit(1)
+ except:
+ pass
+
self.stdioWin = None
self.saveStdio = (sys.stdout, sys.stderr)
return True
def SetWidget(self, widgetClass, *args):
- w = apply(widgetClass, (self.frame,) + args)
+ w = widgetClass(self.frame, *args)
self.frame.Show(True)
#----------------------------------------------------------------------------