1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.AppTraits:
==========================================================================================================================================
|phoenix_title| **wx.AppTraits**
==========================================================================================================================================
The :ref:`wx.AppTraits` class defines various configurable aspects of a :ref:`wx.App`.
You can access it using :meth:`wx.App.GetTraits` function and you can create your own :ref:`wx.AppTraits` overriding the :meth:`wx.App.CreateTraits` function.
Note that :ref:`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 :ref:`wx.AppTraits` and represent concrete implementation of the :ref:`wx.AppTraits` interface.
.. seealso:: :ref:`App Overview <app overview>`, :ref:`wx.App`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>AppTraits</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.AppTraits_inheritance.png" alt="Inheritance diagram of AppTraits" usemap="#dummy" class="inheritance"/></center>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.AppTraits.html" title="wx.AppTraits" alt="" coords="5,5,111,35"/> </map>
</p>
</div>
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.AppTraits.CreateConfig` Called by wxWidgets to create the default configuration object for the application.
:meth:`~wx.AppTraits.CreateEventLoop` Used by wxWidgets to create the main event loop used by :meth:`wx.App.OnRun` .
:meth:`~wx.AppTraits.CreateLogTarget` Creates a :ref:`wx.Log` class for the application to use for logging errors.
:meth:`~wx.AppTraits.GetAssertStackTrace` Helper function mostly useful for derived classes :meth:`~AppTraits.ShowAssertDialog` implementation.
:meth:`~wx.AppTraits.GetDesktopEnvironment` This method returns the name of the desktop environment currently running in a Unix desktop.
:meth:`~wx.AppTraits.GetStandardPaths` Returns the :ref:`wx.StandardPaths` object for the application.
:meth:`~wx.AppTraits.GetToolkitVersion` 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.
:meth:`~wx.AppTraits.HasStderr` Returns ``True`` if ``fprintf(stderr)`` goes somewhere, ``False`` otherwise.
:meth:`~wx.AppTraits.IsUsingUniversalWidgets` Returns ``True`` if the library was built as wxUniversal.
:meth:`~wx.AppTraits.SafeMessageBox` Shows a message box with the given text and title if possible.
:meth:`~wx.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:`~wx.AppTraits.AssertStackTrace` See :meth:`~wx.AppTraits.GetAssertStackTrace`
:attr:`~wx.AppTraits.DesktopEnvironment` See :meth:`~wx.AppTraits.GetDesktopEnvironment`
:attr:`~wx.AppTraits.StandardPaths` See :meth:`~wx.AppTraits.GetStandardPaths`
:attr:`~wx.AppTraits.ToolkitVersion` See :meth:`~wx.AppTraits.GetToolkitVersion`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.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 :ref:`RegConfig` class under MSW and :ref:`wx.FileConfig` under all other platforms.
The :meth:`wx.App.GetAppName` and :meth:`wx.App.GetVendorName` methods are used to determine the registry key or file name.
:rtype: :ref:`wx.ConfigBase`
.. method:: CreateEventLoop(self)
Used by wxWidgets to create the main event loop used by :meth:`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.
:rtype: :ref:`wx.EventLoopBase`
.. method:: CreateLogTarget(self)
Creates a :ref:`wx.Log` class for the application to use for logging errors.
The default implementation returns a new :ref:`wx.LogGui` class.
:rtype: :ref:`wx.Log`
.. seealso:: :ref:`wx.Log`
.. method:: GetAssertStackTrace(self)
Helper function mostly useful for derived classes :meth:`ShowAssertDialog` implementation.
Returns the stack frame as a plain (and possibly empty) :ref:`String`.
This function is only available when ``USE_STACKWALKER`` is 1.
:rtype: `string`
.. versionadded:: 4.1/wxWidgets-3.1.5
.. 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:`wx.StandardPaths` object for the application.
It's normally the same for Base and GUI except in the case of Mac and Cocoa.
:rtype: :ref:`wx.StandardPaths`
.. note::
The returned reference is to a ``StandardPathsBase`` class but you can consider it to be equivalent to :ref:`wx.StandardPaths` (which is documented).
.. method:: 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 :ref:`PlatformInfo` for more details.
If a micro version is not available it will have a value of 0.
:rtype: `tuple`
:returns:
( :ref:`wx.PortId`, `major`, `minor`, `micro` )
.. 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:: 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 :ref:`wx.App`, similarly to :ref:`wx.SafeShowMessage` which is implemented by calling this function and then logging the message to standard error stream if it returned ``False``.
:param `text`: The text to show to the user.
:type `text`: string
:param `title`: The title of the message box shown to the user.
:type `title`: string
:rtype: `bool`
:returns:
``True`` if the message box was shown or ``False`` otherwise.
.. versionadded:: 4.1/wxWidgets-3.1.5
.. 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:: AssertStackTrace
See :meth:`~wx.AppTraits.GetAssertStackTrace`
.. attribute:: DesktopEnvironment
See :meth:`~wx.AppTraits.GetDesktopEnvironment`
.. attribute:: StandardPaths
See :meth:`~wx.AppTraits.GetStandardPaths`
.. attribute:: ToolkitVersion
See :meth:`~wx.AppTraits.GetToolkitVersion`
|