.. include:: headings.inc .. _AppTraits: ========================================================================================================================================== |phoenix_title| **AppTraits** ========================================================================================================================================== The :ref:`AppTraits` class defines various configurable aspects of a :ref:`App`. You can access it using :meth:`App.GetTraits` function and you can create your own :ref:`AppTraits` overriding the :meth:`App.CreateTraits` function. Note that :ref:`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 Library List page) and a ``GUIAppTraits`` object for GUI applications. Both these classes are derived by :ref:`AppTraits` and represent concrete implementation of the :ref:`AppTraits` interface. .. seealso:: :ref:`App Overview `, :ref:`App` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **AppTraits** .. raw:: html

Inheritance diagram of AppTraits

| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~AppTraits.CreateConfig` Called by wxWidgets to create the default configuration object for the application. :meth:`~AppTraits.CreateEventLoop` Used by wxWidgets to create the main event loop used by :meth:`App.OnRun` . :meth:`~AppTraits.CreateLogTarget` Creates a :ref:`Log` class for the application to use for logging errors. :meth:`~AppTraits.GetDesktopEnvironment` This method returns the name of the desktop environment currently running in a Unix desktop. :meth:`~AppTraits.GetStandardPaths` Returns the :ref:`StandardPaths` object for the application. :meth:`~AppTraits.GetToolkitVersion` Returns the wxWidgets port ``ID`` used by the running program and eventually fills the given pointers with the values of the major and minor digits of the native toolkit currently used. :meth:`~AppTraits.HasStderr` Returns ``True`` if ``fprintf(stderr)`` goes somewhere, ``False`` otherwise. :meth:`~AppTraits.IsUsingUniversalWidgets` Returns ``True`` if the library was built as wxUniversal. :meth:`~AppTraits.ShowAssertDialog` Shows the assert dialog with the specified message in GUI mode or just prints the string to stderr in console mode. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~AppTraits.DesktopEnvironment` See :meth:`~AppTraits.GetDesktopEnvironment` :attr:`~AppTraits.StandardPaths` See :meth:`~AppTraits.GetStandardPaths` :attr:`~AppTraits.ToolkitVersion` See :meth:`~AppTraits.GetToolkitVersion` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: AppTraits(object) The AppTraits class defines various configurable aspects of a App. .. method:: 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 :ref:`FileConfig` under all other platforms. The :meth:`App.GetAppName` and :meth:`App.GetVendorName` methods are used to determine the registry key or file name. :rtype: :ref:`ConfigBase` .. method:: CreateEventLoop(self) Used by wxWidgets to create the main event loop used by :meth:`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. :rtype: :ref:`EventLoopBase` .. method:: CreateLogTarget(self) Creates a :ref:`Log` class for the application to use for logging errors. The default implementation returns a new :ref:`LogGui` class. :rtype: :ref:`Log` .. seealso:: :ref:`Log` .. method:: GetDesktopEnvironment(self) This method returns the name of the desktop environment currently running in a Unix desktop. Currently only "``KDE``" or "``GNOME``" are supported and the code uses the X11 session protocol vendor name to figure out, which desktop environment is running. The method returns an empty string otherwise and on all other platforms. :rtype: `string` .. method:: GetStandardPaths(self) Returns the :ref:`StandardPaths` object for the application. It's normally the same for Base and GUI except in the case of Mac and Cocoa. :rtype: :ref:`StandardPaths` .. note:: The returned reference is to a ``StandardPathsBase`` class but you can consider it to be equivalent to :ref:`StandardPaths` (which is documented). .. method:: GetToolkitVersion(self, major=None, minor=None) Returns the wxWidgets port ``ID`` used by the running program and eventually fills the given pointers with the values of the major and minor 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 ``PORT_GTK`` and put in given pointers the versions of the GTK library in use. See :ref:`PlatformInfo` for more details. :param `major`: :type `major`: int :param `minor`: :type `minor`: int :rtype: :ref:`PortId` .. method:: HasStderr(self) Returns ``True`` if ``fprintf(stderr)`` goes somewhere, ``False`` otherwise. :rtype: `bool` .. method:: IsUsingUniversalWidgets(self) Returns ``True`` if the library was built as wxUniversal. Always returns ``False`` for Base-only apps. :rtype: `bool` .. method:: 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. :param `msg`: :type `msg`: string :rtype: `bool` .. attribute:: DesktopEnvironment See :meth:`~AppTraits.GetDesktopEnvironment` .. attribute:: StandardPaths See :meth:`~AppTraits.GetStandardPaths` .. attribute:: ToolkitVersion See :meth:`~AppTraits.GetToolkitVersion`