void _setCallbackInfo(PyObject* self, PyObject* _class);
- // set/get the application name
- wxString GetAppName() const;
- void SetAppName(const wxString& name);
-
- // set/get the app class name
- wxString GetClassName() const;
- void SetClassName(const wxString& name);
-
- // set/get the vendor name
- const wxString& GetVendorName() const;
- void SetVendorName(const wxString& name);
-
- // create the app traits object to which we delegate for everything which
- // either should be configurable by the user (then he can change the
- // default behaviour simply by overriding CreateTraits() and returning his
- // own traits object) or which is GUI/console dependent as then wxAppTraits
- // allows us to abstract the differences behind the common façade
- wxAppTraits *GetTraits();
-
- // process all events in the wxPendingEvents list -- it is necessary to
- // call this function to process posted events. This happens during each
- // event loop iteration.
- virtual void ProcessPendingEvents();
-
- // process all currently pending events right now
- //
- // it is an error to call Yield() recursively unless the value of
- // onlyIfNeeded is True
- //
- // WARNING: this function is dangerous as it can lead to unexpected
- // reentrancies (i.e. when called from an event handler it
- // may result in calling the same event handler again), use
- // with _extreme_ care or, better, don't use at all!
- virtual bool Yield(bool onlyIfNeeded = False);
- // make sure that idle events are sent again
- virtual void WakeUpIdle();
+ DocDeclStr(
+ wxString, GetAppName() const,
+ "Get the application name.");
+ DocDeclStr(
+ void, SetAppName(const wxString& name),
+ "Set the application name. This value may be used automatically\n"
+ "by wxConfig and such.");
+
+ DocDeclStr(
+ wxString, GetClassName() const,
+ "Get the application's class name.");
+ DocDeclStr(
+ void, SetClassName(const wxString& name),
+ "Set the application's class name. This value may be used for X-resources if\n"
+ "applicable for the platform");
+
+ DocDeclStr(
+ const wxString&, GetVendorName() const,
+ "Get the application's vendor name.");
+ DocDeclStr(
+ void, SetVendorName(const wxString& name),
+ "Set the application's vendor name. This value may be used automatically\n"
+ "by wxConfig and such.");
+
+
+ DocDeclStr(
+ wxAppTraits*, GetTraits(),
+ "Create the app traits object to which we delegate for everything which either\n"
+ "should be configurable by the user (then he can change the default behaviour\n"
+ "simply by overriding CreateTraits() and returning his own traits object) or\n"
+ "which is GUI/console dependent as then wxAppTraits allows us to abstract the\n"
+ "differences behind the common facade");
+
+
+ DocDeclStr(
+ virtual void, ProcessPendingEvents(),
+ "Process all events in the wxPendingEvents list -- it is necessary to call this\n"
+ "function to process posted events. This happens during each event loop\n"
+ "iteration.");
+
+
+ DocDeclStr(
+ virtual bool, Yield(bool onlyIfNeeded = False),
+ "Process all currently pending events right now, instead of waiting until\n"
+ "return to the event loop. It is an error to call Yield() recursively unless\n"
+ "the value of onlyIfNeeded is True.\n"
+ "\n"
+ "WARNING: This function is dangerous as it can lead to unexpected\n"
+ " reentrancies (i.e. when called from an event handler it\n"
+ " may result in calling the same event handler again), use\n"
+ " with _extreme_ care or, better, don't use at all!\n");
+
+ DocDeclStr(
+ virtual void, WakeUpIdle(),
+ "Make sure that idle events are sent again");
- // execute the main GUI loop, the function returns when the loop ends
- virtual int MainLoop();
- // exit the main loop thus terminating the application
- virtual void Exit();
+ DocDeclStr(
+ virtual int, MainLoop(),
+ "Execute the main GUI loop, the function returns when the loop ends.");
- // exit the main GUI loop during the next iteration (i.e. it does not
- // stop the program immediately!)
- virtual void ExitMainLoop();
+
+ DocDeclStr(
+ virtual void, Exit(),
+ "Exit the main loop thus terminating the application.");
- // returns True if there are unprocessed events in the event queue
- virtual bool Pending();
+
+ DocDeclStr(
+ virtual void, ExitMainLoop(),
+ "Exit the main GUI loop during the next iteration (i.e. it does not\n"
+ "stop the program immediately!)");
- // process the first event in the event queue (blocks until an event
- // apperas if there are none currently)
- virtual bool Dispatch();
+
+ DocDeclStr(
+ virtual bool, Pending(),
+ "Returns True if there are unprocessed events in the event queue.");
+
+ DocDeclStr(
+ virtual bool, Dispatch(),
+ "Process the first event in the event queue (blocks until an event\n"
+ "appears if there are none currently)");
- // this virtual function is called in the GUI mode when the application
- // becomes idle and normally just sends wxIdleEvent to all interested
- // parties
- //
- // it should return True if more idle events are needed, False if not
- virtual bool ProcessIdle() ;
- // Send idle event to window and all subwindows
- // Returns True if more idle time is requested.
- virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
+ DocDeclStr(
+ virtual bool, ProcessIdle(),
+ "Called from the MainLoop when the application becomes idle and sends an\n"
+ "IdleEvent to all interested parties. Returns True is more idle events are\n"
+ "needed, False if not.");
+
+
+ DocDeclStr(
+ virtual bool, SendIdleEvents(wxWindow* win, wxIdleEvent& event),
+ "Send idle event to window and all subwindows. Returns True if more idle time\n"
+ "is requested.");
- // Perform standard OnIdle behaviour: call from port's OnIdle
- void OnIdle(wxIdleEvent& event);
+ DocDeclStr(
+ virtual bool, IsActive() const,
+ "Return True if our app has focus.");
- // return True if our app has focus
- virtual bool IsActive() const;
+
+ DocDeclStr(
+ void, SetTopWindow(wxWindow *win),
+ "Set the \"main\" top level window");
- // set the "main" top level window
- void SetTopWindow(wxWindow *win);
+ DocDeclStr(
+ virtual wxWindow*, GetTopWindow() const,
+ "Return the \"main\" top level window (if it hadn't been set previously with\n"
+ "SetTopWindow(), will return just some top level window and, if there not any,\n"
+ "will return None)");
- // return the "main" top level window (if it hadn't been set previously
- // with SetTopWindow(), will return just some top level window and, if
- // there are none, will return NULL)
- virtual wxWindow *GetTopWindow() const;
- // control the exit behaviour: by default, the program will exit the
- // main loop (and so, usually, terminate) when the last top-level
- // program window is deleted. Beware that if you disable this behaviour
- // (with SetExitOnFrameDelete(False)), you'll have to call
- // ExitMainLoop() explicitly from somewhere.
- void SetExitOnFrameDelete(bool flag);
- bool GetExitOnFrameDelete() const;
+ DocDeclStr(
+ void, SetExitOnFrameDelete(bool flag),
+ "Control the exit behaviour: by default, the program will exit the main loop\n"
+ "(and so, usually, terminate) when the last top-level program window is\n"
+ "deleted. Beware that if you disable this behaviour (with\n"
+ "SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop() explicitly\n"
+ "from somewhere.\n");
+
+
+ DocDeclStr(
+ bool, GetExitOnFrameDelete() const,
+ "Get the current exit behaviour setting.");
#if 0
// Get display mode that is used use. This is only used in framebuffer
virtual bool SetDisplayMode(const wxVideoMode& info);
#endif
- // set use of best visual flag (see below)
- void SetUseBestVisual( bool flag );
- bool GetUseBestVisual() const;
+
+ DocDeclStr(
+ void, SetUseBestVisual( bool flag ),
+ "Set whether the app should try to use the best available visual on systems\n"
+ "where more than one is available, (Sun, SGI, XFree86 4, etc.)");
+
+ DocDeclStr(
+ bool, GetUseBestVisual() const,
+ "Get current UseBestVisual setting.");
+
// set/get printing mode: see wxPRINT_XXX constants.
//
virtual void SetPrintMode(int mode);
int GetPrintMode() const;
- // Get/Set OnAssert behaviour. The following flags may be or'd together:
- //
- // wxPYAPP_ASSERT_SUPPRESS Don't do anything
- // wxPYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible
- // wxPYAPP_ASSERT_DIALOG Display a message dialog
- // wxPYAPP_ASSERT_LOG Write the assertion info to the wxLog
- int GetAssertMode();
- void SetAssertMode(int mode);
+
+ DocDeclStr(
+ void, SetAssertMode(int mode),
+ "Set the OnAssert behaviour for debug and hybrid builds. The following flags\n"
+ "may be or'd together:\n"
+ "\n"
+ " wxPYAPP_ASSERT_SUPPRESS Don't do anything\n"
+ " wxPYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible (default)\n"
+ " wxPYAPP_ASSERT_DIALOG Display a message dialog\n"
+ " wxPYAPP_ASSERT_LOG Write the assertion info to the wxLog\n");
+
+ DocDeclStr(
+ int, GetAssertMode(),
+ "Get the current OnAssert behaviour setting.");
static bool GetMacSupportPCMenuShortcuts();
static void SetMacExitMenuItemId(long val);
static void SetMacHelpMenuTitleName(const wxString& val);
- // For internal use only
- void _BootstrapApp();
+ DocDeclStr(
+ void, _BootstrapApp(),
+ "For internal use only");
+
+ DocStr(GetComCtl32Version,
+ "Returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it\n"
+ "wasn't found at all. Raises an exception on non-Windows platforms.");
#ifdef __WXMSW__
- // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
- // wasn't found at all
static int GetComCtl32Version();
#else
%extend {
//---------------------------------------------------------------------------
%newgroup;
-// Force an exit from main loop
-void wxExit();
-// Yield to other apps/messages
-bool wxYield();
-bool wxYieldIfNeeded();
-bool wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False);
+DocDeclStr(
+ void, wxExit(),
+ "Force an exit of the application. Convenience for wx.GetApp().Exit()");
+
+
+DocDeclStr(
+ bool, wxYield(),
+ "Yield to other apps/messages. Convenience for wx.GetApp().Yield()");
-// Cause the message queue to become empty again
-void wxWakeUpIdle();
+DocDeclStr(
+ bool, wxYieldIfNeeded(),
+ "Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)");
-// Send an event to be processed later
-void wxPostEvent(wxEvtHandler *dest, wxEvent& event);
-// This is used to cleanup after wxWindows when Python shuts down.
+DocDeclStr(
+ bool, wxSafeYield(wxWindow* win=NULL, bool onlyIfNeeded=False),
+ "This function is similar to wx.Yield, except that it disables the user input\n"
+ "to all program windows before calling wx.Yield and re-enables it again\n"
+ "afterwards. If win is not None, this window will remain enabled, allowing the\n"
+ "implementation of some limited user interaction.\n"
+ "\n"
+ "Returns the result of the call to wx.Yield.");
+
+
+DocDeclStr(
+ void, wxWakeUpIdle(),
+ "Cause the message queue to become empty again, so idle events will be sent.");
+
+
+DocDeclStr(
+ void, wxPostEvent(wxEvtHandler *dest, wxEvent& event),
+ "Send an event to a window or other wx.EvtHandler to be processed later.");
+
+
+DocStr(wxApp_CleanUp,
+ "For internal use only, it is used to cleanup after wxWindows when Python shuts down.");
%inline %{
void wxApp_CleanUp() {
__wxPyCleanup();
}
%}
-// Return a reference to the current wxApp object.
+
+DocStr(wxGetApp,
+ "Return a reference to the current wxApp object.");
%inline %{
wxPyApp* wxGetApp() {
return (wxPyApp*)wxTheApp;
#----------------------------------------------------------------------
class PyOnDemandOutputWindow:
+ """
+ A class that can be used for redirecting Python's stdout and
+ stderr streams. It will do nothing until something is wrriten to
+ the stream at which point it will create a Frame with a text area
+ and write the text there.
+ """
def __init__(self, title = "wxPython: stdout/stderr"):
self.frame = None
self.title = title
self.parent = None
def SetParent(self, parent):
+ """Set the window to be used as the popup Frame's parent."""
self.parent = parent
- def OnCloseWindow(self, event):
- if self.frame != None:
- self.frame.Destroy()
- self.frame = None
- self.text = None
+
+ def CreateOutputWindow(self, st):
+ self.frame = wx.Frame(self.parent, -1, self.title,
+ style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
+ self.text = wxTextCtrl(self.frame, -1, "",
+ style = wx.TE_MULTILINE | wx.TE_READONLY)
+ self.frame.SetSize((450, 300))
+ self.frame.Show(True)
+ EVT_CLOSE(self.frame, self.OnCloseWindow)
+
# These methods provide the file-like output behaviour.
- def write(self, str):
- if not wx.Thread_IsMain():
- # Aquire the GUI mutex before making GUI calls. Mutex is released
- # when locker is deleted at the end of this function.
- locker = wx.MutexGuiLocker()
-
- if not self.frame:
- self.frame = wx.Frame(self.parent, -1, self.title,
- style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
- self.text = wxTextCtrl(self.frame, -1, "",
- style = wx.TE_MULTILINE | wx.TE_READONLY)
- self.frame.SetSize((450, 300))
- self.frame.Show(True)
- EVT_CLOSE(self.frame, self.OnCloseWindow)
- self.text.AppendText(str)
+ def write(self, text):
+ """
+ Create the output window if needed and write the string to it.
+ If not called in the context of the gui thread then uses
+ CallAfter to do the work there.
+ """
+ if self.frame is None:
+ if not wx.Thread_IsMain():
+ wx.CallAfter(self.CreateOutputWindow, text)
+ else:
+ self.CreateOutputWindow(text)
+ else:
+ if not wx.Thread_IsMain():
+ wx.CallAfter(self.text.AppendText, text)
+ else:
+ self.text.AppendText(text)
+
def close(self):
- if self.frame != None:
- if not wx.Thread_IsMain():
- locker = wx.MutexGuiLocker()
- self.frame.Close()
+ if self.frame is not None:
+ wx.CallAfter(self.frame.Close)
+
+ def OnCloseWindow(self, event):
+ if self.frame is not None:
+ self.frame.Destroy()
+ self.frame = None
+ self.text = None
#----------------------------------------------------------------------
-# The main application class. Derive from this and implement an OnInit
-# method that creates a frame and then calls self.SetTopWindow(frame)
_defRedirect = (wx.Platform == '__WXMSW__' or wx.Platform == '__WXMAC__')
class App(wx.PyApp):
+ """
+ The main application class. Derive from this and implement an OnInit
+ method that creates a frame and then calls self.SetTopWindow(frame)
+ """
outputWindowClass = PyOnDemandOutputWindow
def __init__(self, redirect=_defRedirect, filename=None, useBestVisual=False):
#----------------------------------------------------------------------------
class PySimpleApp(wx.App):
- def __init__(self, redirect=False, filename=None):
- wx.App.__init__(self, redirect, filename)
+ """
+ A simple application class. You can just create one of these and
+ then then make your top level windows later, and not have to worry
+ about OnInit."""
+
+ def __init__(self, redirect=False, filename=None, useBestVisual=False):
+ wx.App.__init__(self, redirect, filename, useBestVisual)
+
def OnInit(self):
wx.InitAllImageHandlers()
return True
+# Is anybody using this one?
class PyWidgetTester(wx.App):
def __init__(self, size = (250, 100)):
self.size = size
wxLayoutConstraints();
- bool SatisfyConstraints(wxWindow *win, int *OUTPUT);
+
+ DocDeclA(
+ bool, SatisfyConstraints(wxWindow *win, int *OUTPUT),
+ "SatisfyConstraints(Window win) -> (areSatisfied, noChanges)");
+
bool AreSatisfied() const;
};
~wxWave();
bool IsOk() const;
- bool Play(bool async = True, bool looped = False) const;
+ bool Play(bool async = True, bool looped = False);
%pythoncode { def __nonzero__(self): return self.IsOk() }
};
return _core.PyApp__setCallbackInfo(*args, **kwargs)
def GetAppName(*args, **kwargs):
- """GetAppName() -> wxString"""
+ """GetAppName() -> wxString
+
+Get the application name."""
return _core.PyApp_GetAppName(*args, **kwargs)
def SetAppName(*args, **kwargs):
- """SetAppName(wxString name)"""
+ """SetAppName(wxString name)
+
+Set the application name. This value may be used automatically
+by wxConfig and such."""
return _core.PyApp_SetAppName(*args, **kwargs)
def GetClassName(*args, **kwargs):
"""GetClassName() -> wxString
-Returns the class name of the C++ object using wxRTTI."""
+Get the application's class name."""
return _core.PyApp_GetClassName(*args, **kwargs)
def SetClassName(*args, **kwargs):
- """SetClassName(wxString name)"""
+ """SetClassName(wxString name)
+
+Set the application's class name. This value may be used for X-resources if
+applicable for the platform"""
return _core.PyApp_SetClassName(*args, **kwargs)
def GetVendorName(*args, **kwargs):
- """GetVendorName() -> wxString"""
+ """GetVendorName() -> wxString
+
+Get the application's vendor name."""
return _core.PyApp_GetVendorName(*args, **kwargs)
def SetVendorName(*args, **kwargs):
- """SetVendorName(wxString name)"""
+ """SetVendorName(wxString name)
+
+Set the application's vendor name. This value may be used automatically
+by wxConfig and such."""
return _core.PyApp_SetVendorName(*args, **kwargs)
def GetTraits(*args, **kwargs):
- """GetTraits() -> wxAppTraits"""
+ """GetTraits() -> wxAppTraits
+
+Create the app traits object to which we delegate for everything which either
+should be configurable by the user (then he can change the default behaviour
+simply by overriding CreateTraits() and returning his own traits object) or
+which is GUI/console dependent as then wxAppTraits allows us to abstract the
+differences behind the common facade"""
return _core.PyApp_GetTraits(*args, **kwargs)
def ProcessPendingEvents(*args, **kwargs):
- """ProcessPendingEvents()"""
+ """ProcessPendingEvents()
+
+Process all events in the wxPendingEvents list -- it is necessary to call this
+function to process posted events. This happens during each event loop
+iteration."""
return _core.PyApp_ProcessPendingEvents(*args, **kwargs)
def Yield(*args, **kwargs):
- """Yield(bool onlyIfNeeded=False) -> bool"""
+ """Yield(bool onlyIfNeeded=False) -> bool
+
+Process all currently pending events right now, instead of waiting until
+return to the event loop. It is an error to call Yield() recursively unless
+the value of onlyIfNeeded is True.
+
+WARNING: This function is dangerous as it can lead to unexpected
+ reentrancies (i.e. when called from an event handler it
+ may result in calling the same event handler again), use
+ with _extreme_ care or, better, don't use at all!
+"""
return _core.PyApp_Yield(*args, **kwargs)
def WakeUpIdle(*args, **kwargs):
- """WakeUpIdle()"""
+ """WakeUpIdle()
+
+Make sure that idle events are sent again"""
return _core.PyApp_WakeUpIdle(*args, **kwargs)
def MainLoop(*args, **kwargs):
- """MainLoop() -> int"""
+ """MainLoop() -> int
+
+Execute the main GUI loop, the function returns when the loop ends."""
return _core.PyApp_MainLoop(*args, **kwargs)
def Exit(*args, **kwargs):
- """Exit()"""
+ """Exit()
+
+Exit the main loop thus terminating the application."""
return _core.PyApp_Exit(*args, **kwargs)
def ExitMainLoop(*args, **kwargs):
- """ExitMainLoop()"""
+ """ExitMainLoop()
+
+Exit the main GUI loop during the next iteration (i.e. it does not
+stop the program immediately!)"""
return _core.PyApp_ExitMainLoop(*args, **kwargs)
def Pending(*args, **kwargs):
- """Pending() -> bool"""
+ """Pending() -> bool
+
+Returns True if there are unprocessed events in the event queue."""
return _core.PyApp_Pending(*args, **kwargs)
def Dispatch(*args, **kwargs):
- """Dispatch() -> bool"""
+ """Dispatch() -> bool
+
+Process the first event in the event queue (blocks until an event
+appears if there are none currently)"""
return _core.PyApp_Dispatch(*args, **kwargs)
def ProcessIdle(*args, **kwargs):
- """ProcessIdle() -> bool"""
+ """ProcessIdle() -> bool
+
+Called from the MainLoop when the application becomes idle and sends an
+IdleEvent to all interested parties. Returns True is more idle events are
+needed, False if not."""
return _core.PyApp_ProcessIdle(*args, **kwargs)
def SendIdleEvents(*args, **kwargs):
- """SendIdleEvents(Window win, IdleEvent event) -> bool"""
- return _core.PyApp_SendIdleEvents(*args, **kwargs)
+ """SendIdleEvents(Window win, IdleEvent event) -> bool
- def OnIdle(*args, **kwargs):
- """OnIdle(IdleEvent event)"""
- return _core.PyApp_OnIdle(*args, **kwargs)
+Send idle event to window and all subwindows. Returns True if more idle time
+is requested."""
+ return _core.PyApp_SendIdleEvents(*args, **kwargs)
def IsActive(*args, **kwargs):
- """IsActive() -> bool"""
+ """IsActive() -> bool
+
+Return True if our app has focus."""
return _core.PyApp_IsActive(*args, **kwargs)
def SetTopWindow(*args, **kwargs):
- """SetTopWindow(Window win)"""
+ """SetTopWindow(Window win)
+
+Set the "main" top level window"""
return _core.PyApp_SetTopWindow(*args, **kwargs)
def GetTopWindow(*args, **kwargs):
- """GetTopWindow() -> Window"""
+ """GetTopWindow() -> Window
+
+Return the "main" top level window (if it hadn't been set previously with
+SetTopWindow(), will return just some top level window and, if there not any,
+will return None)"""
return _core.PyApp_GetTopWindow(*args, **kwargs)
def SetExitOnFrameDelete(*args, **kwargs):
- """SetExitOnFrameDelete(bool flag)"""
+ """SetExitOnFrameDelete(bool flag)
+
+Control the exit behaviour: by default, the program will exit the main loop
+(and so, usually, terminate) when the last top-level program window is
+deleted. Beware that if you disable this behaviour (with
+SetExitOnFrameDelete(False)), you'll have to call ExitMainLoop() explicitly
+from somewhere.
+"""
return _core.PyApp_SetExitOnFrameDelete(*args, **kwargs)
def GetExitOnFrameDelete(*args, **kwargs):
- """GetExitOnFrameDelete() -> bool"""
+ """GetExitOnFrameDelete() -> bool
+
+Get the current exit behaviour setting."""
return _core.PyApp_GetExitOnFrameDelete(*args, **kwargs)
def SetUseBestVisual(*args, **kwargs):
- """SetUseBestVisual(bool flag)"""
+ """SetUseBestVisual(bool flag)
+
+Set whether the app should try to use the best available visual on systems
+where more than one is available, (Sun, SGI, XFree86 4, etc.)"""
return _core.PyApp_SetUseBestVisual(*args, **kwargs)
def GetUseBestVisual(*args, **kwargs):
- """GetUseBestVisual() -> bool"""
+ """GetUseBestVisual() -> bool
+
+Get current UseBestVisual setting."""
return _core.PyApp_GetUseBestVisual(*args, **kwargs)
def SetPrintMode(*args, **kwargs):
"""GetPrintMode() -> int"""
return _core.PyApp_GetPrintMode(*args, **kwargs)
- def GetAssertMode(*args, **kwargs):
- """GetAssertMode() -> int"""
- return _core.PyApp_GetAssertMode(*args, **kwargs)
-
def SetAssertMode(*args, **kwargs):
- """SetAssertMode(int mode)"""
+ """SetAssertMode(int mode)
+
+Set the OnAssert behaviour for debug and hybrid builds. The following flags
+may be or'd together:
+
+ wxPYAPP_ASSERT_SUPPRESS Don't do anything
+ wxPYAPP_ASSERT_EXCEPTION Turn it into a Python exception if possible (default)
+ wxPYAPP_ASSERT_DIALOG Display a message dialog
+ wxPYAPP_ASSERT_LOG Write the assertion info to the wxLog
+"""
return _core.PyApp_SetAssertMode(*args, **kwargs)
+ def GetAssertMode(*args, **kwargs):
+ """GetAssertMode() -> int
+
+Get the current OnAssert behaviour setting."""
+ return _core.PyApp_GetAssertMode(*args, **kwargs)
+
def GetMacSupportPCMenuShortcuts(*args, **kwargs):
"""PyApp.GetMacSupportPCMenuShortcuts() -> bool"""
return _core.PyApp_GetMacSupportPCMenuShortcuts(*args, **kwargs)
SetMacHelpMenuTitleName = staticmethod(SetMacHelpMenuTitleName)
def _BootstrapApp(*args, **kwargs):
- """_BootstrapApp()"""
+ """_BootstrapApp()
+
+For internal use only"""
return _core.PyApp__BootstrapApp(*args, **kwargs)
def GetComCtl32Version(*args, **kwargs):
- """PyApp.GetComCtl32Version() -> int"""
+ """PyApp.GetComCtl32Version() -> int
+
+Returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
+wasn't found at all. Raises an exception on non-Windows platforms."""
return _core.PyApp_GetComCtl32Version(*args, **kwargs)
GetComCtl32Version = staticmethod(GetComCtl32Version)
return _core.PyApp_SetMacHelpMenuTitleName(*args, **kwargs)
def PyApp_GetComCtl32Version(*args, **kwargs):
- """PyApp_GetComCtl32Version() -> int"""
+ """PyApp_GetComCtl32Version() -> int
+
+Returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
+wasn't found at all. Raises an exception on non-Windows platforms."""
return _core.PyApp_GetComCtl32Version(*args, **kwargs)
#---------------------------------------------------------------------------
def Exit(*args, **kwargs):
- """Exit()"""
+ """Exit()
+
+Force an exit of the application. Convenience for wx.GetApp().Exit()"""
return _core.Exit(*args, **kwargs)
def Yield(*args, **kwargs):
- """Yield() -> bool"""
+ """Yield() -> bool
+
+Yield to other apps/messages. Convenience for wx.GetApp().Yield()"""
return _core.Yield(*args, **kwargs)
def YieldIfNeeded(*args, **kwargs):
- """YieldIfNeeded() -> bool"""
+ """YieldIfNeeded() -> bool
+
+Yield to other apps/messages. Convenience for wx.GetApp().Yield(True)"""
return _core.YieldIfNeeded(*args, **kwargs)
def SafeYield(*args, **kwargs):
- """SafeYield(Window win=None, bool onlyIfNeeded=False) -> bool"""
+ """SafeYield(Window win=None, bool onlyIfNeeded=False) -> bool
+
+This function is similar to wx.Yield, except that it disables the user input
+to all program windows before calling wx.Yield and re-enables it again
+afterwards. If win is not None, this window will remain enabled, allowing the
+implementation of some limited user interaction.
+
+Returns the result of the call to wx.Yield."""
return _core.SafeYield(*args, **kwargs)
def WakeUpIdle(*args, **kwargs):
- """WakeUpIdle()"""
+ """WakeUpIdle()
+
+Cause the message queue to become empty again, so idle events will be sent."""
return _core.WakeUpIdle(*args, **kwargs)
def PostEvent(*args, **kwargs):
- """PostEvent(EvtHandler dest, Event event)"""
+ """PostEvent(EvtHandler dest, Event event)
+
+Send an event to a window or other wx.EvtHandler to be processed later."""
return _core.PostEvent(*args, **kwargs)
def App_CleanUp(*args, **kwargs):
- """App_CleanUp()"""
+ """App_CleanUp()
+
+For internal use only, it is used to cleanup after wxWindows when Python shuts down."""
return _core.App_CleanUp(*args, **kwargs)
def GetApp(*args, **kwargs):
- """GetApp() -> PyApp"""
+ """GetApp() -> PyApp
+
+Return a reference to the current wxApp object."""
return _core.GetApp(*args, **kwargs)
#----------------------------------------------------------------------
class PyOnDemandOutputWindow:
+ """
+ A class that can be used for redirecting Python's stdout and
+ stderr streams. It will do nothing until something is wrriten to
+ the stream at which point it will create a Frame with a text area
+ and write the text there.
+ """
def __init__(self, title = "wxPython: stdout/stderr"):
self.frame = None
self.title = title
self.parent = None
def SetParent(self, parent):
+ """Set the window to be used as the popup Frame's parent."""
self.parent = parent
- def OnCloseWindow(self, event):
- if self.frame != None:
- self.frame.Destroy()
- self.frame = None
- self.text = None
+
+ def CreateOutputWindow(self, st):
+ self.frame = wx.Frame(self.parent, -1, self.title,
+ style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
+ self.text = wxTextCtrl(self.frame, -1, "",
+ style = wx.TE_MULTILINE | wx.TE_READONLY)
+ self.frame.SetSize((450, 300))
+ self.frame.Show(True)
+ EVT_CLOSE(self.frame, self.OnCloseWindow)
+
# These methods provide the file-like output behaviour.
- def write(self, str):
- if not wx.Thread_IsMain():
- # Aquire the GUI mutex before making GUI calls. Mutex is released
- # when locker is deleted at the end of this function.
- locker = wx.MutexGuiLocker()
-
- if not self.frame:
- self.frame = wx.Frame(self.parent, -1, self.title,
- style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
- self.text = wxTextCtrl(self.frame, -1, "",
- style = wx.TE_MULTILINE | wx.TE_READONLY)
- self.frame.SetSize((450, 300))
- self.frame.Show(True)
- EVT_CLOSE(self.frame, self.OnCloseWindow)
- self.text.AppendText(str)
+ def write(self, text):
+ """
+ Create the output window if needed and write the string to it.
+ If not called in the context of the gui thread then uses
+ CallAfter to do the work there.
+ """
+ if self.frame is None:
+ if not wx.Thread_IsMain():
+ wx.CallAfter(self.CreateOutputWindow, text)
+ else:
+ self.CreateOutputWindow(text)
+ else:
+ if not wx.Thread_IsMain():
+ wx.CallAfter(self.text.AppendText, text)
+ else:
+ self.text.AppendText(text)
+
def close(self):
- if self.frame != None:
- if not wx.Thread_IsMain():
- locker = wx.MutexGuiLocker()
- self.frame.Close()
+ if self.frame is not None:
+ wx.CallAfter(self.frame.Close)
+
+ def OnCloseWindow(self, event):
+ if self.frame is not None:
+ self.frame.Destroy()
+ self.frame = None
+ self.text = None
#----------------------------------------------------------------------
-# The main application class. Derive from this and implement an OnInit
-# method that creates a frame and then calls self.SetTopWindow(frame)
_defRedirect = (wx.Platform == '__WXMSW__' or wx.Platform == '__WXMAC__')
class App(wx.PyApp):
+ """
+ The main application class. Derive from this and implement an OnInit
+ method that creates a frame and then calls self.SetTopWindow(frame)
+ """
outputWindowClass = PyOnDemandOutputWindow
def __init__(self, redirect=_defRedirect, filename=None, useBestVisual=False):
#----------------------------------------------------------------------------
class PySimpleApp(wx.App):
- def __init__(self, redirect=False, filename=None):
- wx.App.__init__(self, redirect, filename)
+ """
+ A simple application class. You can just create one of these and
+ then then make your top level windows later, and not have to worry
+ about OnInit."""
+
+ def __init__(self, redirect=False, filename=None, useBestVisual=False):
+ wx.App.__init__(self, redirect, filename, useBestVisual)
+
def OnInit(self):
wx.InitAllImageHandlers()
return True
+# Is anybody using this one?
class PyWidgetTester(wx.App):
def __init__(self, size = (250, 100)):
self.size = size
self.thisown = 1
del newobj.thisown
def SatisfyConstraints(*args, **kwargs):
- """SatisfyConstraints(Window win, int OUTPUT) -> bool"""
+ """SatisfyConstraints(Window win) -> (areSatisfied, noChanges)"""
return _core.LayoutConstraints_SatisfyConstraints(*args, **kwargs)
def AreSatisfied(*args, **kwargs):
}
-static PyObject *_wrap_PyApp_OnIdle(PyObject *self, PyObject *args, PyObject *kwargs) {
- PyObject *resultobj;
- wxPyApp *arg1 = (wxPyApp *) 0 ;
- wxIdleEvent *arg2 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char *kwnames[] = {
- (char *) "self",(char *) "event", NULL
- };
-
- if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:PyApp_OnIdle",kwnames,&obj0,&obj1)) goto fail;
- if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_wxPyApp,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_wxIdleEvent,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
- if (arg2 == NULL) {
- PyErr_SetString(PyExc_TypeError,"null reference"); SWIG_fail;
- }
- {
- PyThreadState* __tstate = wxPyBeginAllowThreads();
- (arg1)->OnIdle(*arg2);
-
- wxPyEndAllowThreads(__tstate);
- if (PyErr_Occurred()) SWIG_fail;
- }
- Py_INCREF(Py_None); resultobj = Py_None;
- return resultobj;
- fail:
- return NULL;
-}
-
-
static PyObject *_wrap_PyApp_IsActive(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject *resultobj;
wxPyApp *arg1 = (wxPyApp *) 0 ;
}
-static PyObject *_wrap_PyApp_GetAssertMode(PyObject *self, PyObject *args, PyObject *kwargs) {
+static PyObject *_wrap_PyApp_SetAssertMode(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject *resultobj;
wxPyApp *arg1 = (wxPyApp *) 0 ;
- int result;
+ int arg2 ;
PyObject * obj0 = 0 ;
char *kwnames[] = {
- (char *) "self", NULL
+ (char *) "self",(char *) "mode", NULL
};
- if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:PyApp_GetAssertMode",kwnames,&obj0)) goto fail;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"Oi:PyApp_SetAssertMode",kwnames,&obj0,&arg2)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_wxPyApp,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
- result = (int)(arg1)->GetAssertMode();
+ (arg1)->SetAssertMode(arg2);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) SWIG_fail;
}
- resultobj = PyInt_FromLong((long)result);
+ Py_INCREF(Py_None); resultobj = Py_None;
return resultobj;
fail:
return NULL;
}
-static PyObject *_wrap_PyApp_SetAssertMode(PyObject *self, PyObject *args, PyObject *kwargs) {
+static PyObject *_wrap_PyApp_GetAssertMode(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject *resultobj;
wxPyApp *arg1 = (wxPyApp *) 0 ;
- int arg2 ;
+ int result;
PyObject * obj0 = 0 ;
char *kwnames[] = {
- (char *) "self",(char *) "mode", NULL
+ (char *) "self", NULL
};
- if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"Oi:PyApp_SetAssertMode",kwnames,&obj0,&arg2)) goto fail;
+ if(!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:PyApp_GetAssertMode",kwnames,&obj0)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_wxPyApp,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
- (arg1)->SetAssertMode(arg2);
+ result = (int)(arg1)->GetAssertMode();
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) SWIG_fail;
}
- Py_INCREF(Py_None); resultobj = Py_None;
+ resultobj = PyInt_FromLong((long)result);
return resultobj;
fail:
return NULL;
{ (char *)"PyApp_Dispatch", (PyCFunction) _wrap_PyApp_Dispatch, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_ProcessIdle", (PyCFunction) _wrap_PyApp_ProcessIdle, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_SendIdleEvents", (PyCFunction) _wrap_PyApp_SendIdleEvents, METH_VARARGS | METH_KEYWORDS },
- { (char *)"PyApp_OnIdle", (PyCFunction) _wrap_PyApp_OnIdle, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_IsActive", (PyCFunction) _wrap_PyApp_IsActive, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_SetTopWindow", (PyCFunction) _wrap_PyApp_SetTopWindow, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_GetTopWindow", (PyCFunction) _wrap_PyApp_GetTopWindow, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_GetUseBestVisual", (PyCFunction) _wrap_PyApp_GetUseBestVisual, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_SetPrintMode", (PyCFunction) _wrap_PyApp_SetPrintMode, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_GetPrintMode", (PyCFunction) _wrap_PyApp_GetPrintMode, METH_VARARGS | METH_KEYWORDS },
- { (char *)"PyApp_GetAssertMode", (PyCFunction) _wrap_PyApp_GetAssertMode, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_SetAssertMode", (PyCFunction) _wrap_PyApp_SetAssertMode, METH_VARARGS | METH_KEYWORDS },
+ { (char *)"PyApp_GetAssertMode", (PyCFunction) _wrap_PyApp_GetAssertMode, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_GetMacSupportPCMenuShortcuts", (PyCFunction) _wrap_PyApp_GetMacSupportPCMenuShortcuts, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_GetMacAboutMenuItemId", (PyCFunction) _wrap_PyApp_GetMacAboutMenuItemId, METH_VARARGS | METH_KEYWORDS },
{ (char *)"PyApp_GetMacPreferencesMenuItemId", (PyCFunction) _wrap_PyApp_GetMacPreferencesMenuItemId, METH_VARARGS | METH_KEYWORDS },
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
- result = (bool)((wxWave const *)arg1)->Play(arg2,arg3);
+ result = (bool)(arg1)->Play(arg2,arg3);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) SWIG_fail;