wx.AppTraits¶
The wx.AppTraits class defines various configurable aspects of a wx.App.
You can access it using wx.App.GetTraits
function and you can create your own wx.AppTraits overriding the wx.App.CreateTraits
function.
Note that wx.AppTraits is an abstract class since it contains many pure virtual functions. In fact, by default, wxWidgets creates a ConsoleAppTraits
object for console applications (i.e. those applications linked against Base library only - see the page) and a GUIAppTraits
object for GUI applications. Both these classes are derived by wx.AppTraits and represent concrete implementation of the wx.AppTraits interface.
See also
Class Hierarchy¶
Methods Summary¶
Called by wxWidgets to create the default configuration object for the application. |
|
Used by wxWidgets to create the main event loop used by |
|
Creates a wx.Log class for the application to use for logging errors. |
|
Helper function mostly useful for derived classes |
|
Returns the name of the desktop environment currently running on a Unix desktop. |
|
Returns the wx.StandardPaths object for the application. |
|
Returns the wxWidgets port |
|
Returns |
|
Returns |
|
Shows a message box with the given text and title if possible. |
|
Shows the assert dialog with the specified message in GUI mode or just prints the string to stderr in console mode. |
Properties Summary¶
See |
|
Class API¶
- class wx.AppTraits(object)¶
The AppTraits class defines various configurable aspects of a App.
Methods¶
- CreateConfig(self)¶
Called by wxWidgets to create the default configuration object for the application.
The default version creates a registry-based RegConfig class under MSW and wx.FileConfig under all other platforms.
The
wx.App.GetAppName
andwx.App.GetVendorName
methods are used to determine the registry key or file name.- Return type:
- CreateEventLoop(self)¶
Used by wxWidgets to create the main event loop used by
wx.App.OnRun
.The default implementation of this method in GUIAppTraits returns the usual platform-specific GUI event loop. The version in ConsoleAppTraits returns a console-specific event loop which can be used to handle timer and socket events in console programs under Unix and MSW or
None
under the other platforms where console event loops are not supported yet.- Return type:
- CreateLogTarget(self)¶
Creates a wx.Log class for the application to use for logging errors.
The default implementation returns a new wx.LogGui class.
- Return type:
See also
- GetAssertStackTrace(self)¶
Helper function mostly useful for derived classes
ShowAssertDialog
implementation.Returns the stack frame as a plain (and possibly empty) String .
This function is only available when
USE_STACKWALKER
is 1.- Return type:
str
Added in version 4.1/wxWidgets-3.1.5.
- GetDesktopEnvironment(self)¶
Returns the name of the desktop environment currently running on a Unix desktop.
It returns an empty string for platforms other than wxGTK, or if the desktop environment could not be determined.
- Return type:
str
- GetStandardPaths(self)¶
Returns the wx.StandardPaths object for the application.
It’s normally the same for Base and GUI except in the case of Mac and Cocoa.
- Return type:
Note
The returned reference is to a
StandardPathsBase
class but you can consider it to be equivalent to wx.StandardPaths (which is documented).
- GetToolkitVersion(self)¶
Returns the wxWidgets port
ID
used by the running program and eventually fills the given pointers with the values of the major, minor, and micro digits of the native toolkit currently used.The version numbers returned are thus detected at run-time and not compile-time (except when this is not possible e.g. Motif).
E.g. if your program is using wxGTK port this function will return
wx.PORT_GTK
and put in given pointers the versions of the GTK library in use. See PlatformInfo for more details.If a micro version is not available it will have a value of 0.
- Return type:
Tuple[PortId, int, int, int]
- HasStderr(self)¶
Returns
True
iffprintf(stderr)
goes somewhere,False
otherwise.- Return type:
bool
- IsUsingUniversalWidgets(self)¶
Returns
True
if the library was built as wxUniversal.Always returns
False
for Base-only apps.- Return type:
bool
- SafeMessageBox(self, text, title)¶
Shows a message box with the given text and title if possible.
In some ports, e.g. wxMSW, a message box will always be shown, while in the other ones it will be only done if the GUI is available (e.g. X11 display was successfully opened for X11-based ports) and the function simply returns
False
without doing anything otherwise.This function is safe in the sense that it can always be called, even before creating wx.App, similarly to
wx.SafeShowMessage
which is implemented by calling this function and then logging the message to standard error stream if it returnedFalse
.- Parameters:
text (string) – The text to show to the user.
title (string) – The title of the message box shown to the user.
- Return type:
bool
- Returns:
True
if the message box was shown orFalse
otherwise.
Added in version 4.1/wxWidgets-3.1.5.
- ShowAssertDialog(self, msg)¶
Shows the assert dialog with the specified message in GUI mode or just prints the string to stderr in console mode.
Returns
True
to suppress subsequent asserts,False
to continue as before.- Parameters:
msg (string)
- Return type:
bool
Properties¶
- AssertStackTrace¶
- DesktopEnvironment¶
- StandardPaths¶
See
GetStandardPaths
- ToolkitVersion¶