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 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.PyApp:
==========================================================================================================================================
|phoenix_title| **wx.PyApp**
==========================================================================================================================================
The :ref:`wx.App` class represents the application itself when ``USE_GUI=1`` .
In addition to the features provided by :ref:`wx.AppConsole` it keeps track of the `top window` (see :meth:`~wx.PyApp.SetTopWindow`) and adds support for video modes (see SetVideoMode()).
In general, application-wide settings for GUI-only apps are accessible from :ref:`wx.App` (or from :ref:`wx.SystemSettings` or :ref:`wx.SystemOptions` classes).
.. _PyApp-events:
|events| Events Emitted by this Class
=====================================
Event macros for events emitted by this class:
- EVT_QUERY_END_SESSION: Process a query end session event, supplying the member function. See :ref:`wx.CloseEvent`.
- EVT_END_SESSION: Process an end session event, supplying the member function. See :ref:`wx.CloseEvent`.
- EVT_ACTIVATE_APP: Process a ``wxEVT_ACTIVATE_APP`` event. See :ref:`wx.ActivateEvent`.
- EVT_HIBERNATE: Process a hibernate event. See :ref:`wx.ActivateEvent`.
- EVT_DIALUP_CONNECTED: A connection with the network was established. See :ref:`DialUpEvent`.
- EVT_DIALUP_DISCONNECTED: The connection with the network was lost. See :ref:`DialUpEvent`.
- EVT_IDLE: Process a ``wxEVT_IDLE`` event. See :ref:`wx.IdleEvent`.
.. seealso:: :ref:`App Overview <app overview>`, :ref:`wx.AppTraits`, :ref:`wx.EventLoopBase`, :ref:`wx.SystemSettings`
|
|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>PyApp</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.App_inheritance.png" alt="Inheritance diagram of PyApp" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.EventFilter.html" title="wx.EventFilter" alt="" coords="5,83,112,112"/> <area shape="rect" id="node3" href="wx.AppConsole.html" title="wx.AppConsole" alt="" coords="66,160,184,189"/> <area shape="rect" id="node2" href="wx.App.html" title="wx.App" alt="" coords="89,237,161,267"/> <area shape="rect" id="node4" href="wx.Object.html" title="wx.Object" alt="" coords="93,5,175,35"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="137,83,248,112"/> <area shape="rect" id="node6" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="200,5,301,35"/> </map>
</p>
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.PyApp.__init__` Constructor.
:meth:`~wx.PyApp.GetAssertMode` Returns the current mode for how the application responds to asserts.
:meth:`~wx.PyApp.GetComCtl32Version` Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or 0 if
:meth:`~wx.PyApp.GetDisplayMode` Get display mode that is used use.
:meth:`~wx.PyApp.GetExitOnFrameDelete` Returns ``True`` if the application will exit when the top-level frame is deleted.
:meth:`~wx.PyApp.GetLayoutDirection` Return the layout direction for the current locale or ``Layout_Default`` if it's unknown.
:meth:`~wx.PyApp.GetShell32Version` Returns 400, 470, 471, etc. for shell32.dll 4.00, 4.70, 4.71 or 0 if
:meth:`~wx.PyApp.GetTopWindow` Returns a pointer to the top window.
:meth:`~wx.PyApp.GetUseBestVisual` Returns ``True`` if the application will use the best visual on systems that support different visuals, ``False`` otherwise.
:meth:`~wx.PyApp.IsActive` Returns ``True`` if the application is active, i.e. if one of its windows is currently in the foreground.
:meth:`~wx.PyApp.IsDisplayAvailable` Returns True if the application is able to connect to the system's
:meth:`~wx.PyApp.MacHideApp` Hide all application windows just as the user can do with the
:meth:`~wx.PyApp.MacNewFile` Called in response of an "open-application" Apple event.
:meth:`~wx.PyApp.MacOpenFile` Called in response of an "open-document" Apple event.
:meth:`~wx.PyApp.MacOpenFiles` Called in response of an openFiles message with Cocoa, or an "open-document" Apple event with Carbon.
:meth:`~wx.PyApp.MacOpenURL` Called in response of a "get-url" Apple event.
:meth:`~wx.PyApp.MacPrintFile` Called in response of a "print-document" Apple event.
:meth:`~wx.PyApp.MacReopenApp` Called in response of a "reopen-application" Apple event.
:meth:`~wx.PyApp.OSXIsGUIApplication` May be overridden to indicate that the application is not a foreground GUI application under OS X.
:meth:`~wx.PyApp.SafeYield` This function is similar to :ref:`wx.Yield`, except that it disables the user input to all program windows before calling :meth:`wx.AppConsole.Yield` and re-enables it again afterwards.
:meth:`~wx.PyApp.SafeYieldFor` Works like :ref:`wx.SafeYield` with `onlyIfNeeded` == ``True`` except that it allows the caller to specify a mask of events to be processed.
:meth:`~wx.PyApp.SetAssertMode` Set the mode indicating how the application responds to assertion
:meth:`~wx.PyApp.SetDisplayMode` Set display mode to use.
:meth:`~wx.PyApp.SetExitOnFrameDelete` Allows the programmer to specify whether the application will exit when the top-level frame is deleted.
:meth:`~wx.PyApp.SetNativeTheme` Allows runtime switching of the UI environment theme.
:meth:`~wx.PyApp.SetTopWindow` Sets the 'top' window.
:meth:`~wx.PyApp.SetUseBestVisual` Allows the programmer to specify whether the application will use the best visual on systems that support several visual on the same display.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.PyApp.AssertMode` See :meth:`~wx.PyApp.GetAssertMode` and :meth:`~wx.PyApp.SetAssertMode`
:attr:`~wx.PyApp.DisplayMode` See :meth:`~wx.PyApp.GetDisplayMode` and :meth:`~wx.PyApp.SetDisplayMode`
:attr:`~wx.PyApp.ExitOnFrameDelete` See :meth:`~wx.PyApp.GetExitOnFrameDelete` and :meth:`~wx.PyApp.SetExitOnFrameDelete`
:attr:`~wx.PyApp.LayoutDirection` See :meth:`~wx.PyApp.GetLayoutDirection`
:attr:`~wx.PyApp.TopWindow` See :meth:`~wx.PyApp.GetTopWindow` and :meth:`~wx.PyApp.SetTopWindow`
:attr:`~wx.PyApp.UseBestVisual` See :meth:`~wx.PyApp.GetUseBestVisual` and :meth:`~wx.PyApp.SetUseBestVisual`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.PyApp(AppConsole)
**Possible constructors**::
PyApp()
The App class represents the application itself when USE_GUI=1.
.. method:: __init__(self)
Constructor.
Called implicitly with a definition of a :ref:`wx.App` object.
.. method:: GetAssertMode(self)
Returns the current mode for how the application responds to asserts.
:rtype: :ref:`wx.AppAssertMode`
.. staticmethod:: GetComCtl32Version()
Returns 400, 470, 471, etc. 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.
:rtype: `int`
.. method:: GetDisplayMode(self)
Get display mode that is used use.
This is only used in framebuffer wxWidgets ports such as wxDFB.
:rtype: :ref:`wx.VideoMode`
.. method:: GetExitOnFrameDelete(self)
Returns ``True`` if the application will exit when the top-level frame is deleted.
:rtype: `bool`
.. seealso:: :meth:`SetExitOnFrameDelete`
.. method:: GetLayoutDirection(self)
Return the layout direction for the current locale or ``Layout_Default`` if it's unknown.
:rtype: :ref:`wx.LayoutDirection`
.. staticmethod:: GetShell32Version()
Returns 400, 470, 471, etc. for shell32.dll 4.00, 4.70, 4.71 or 0 if
it wasn't found at all. Raises an exception on non-Windows platforms.
:rtype: `int`
.. method:: GetTopWindow(self)
Returns a pointer to the top window.
:rtype: :ref:`wx.Window`
.. note::
If the top window hasn't been set using :meth:`SetTopWindow` , this function will find the first top-level window (frame or dialog or instance of :ref:`wx.TopLevelWindow`) from the internal top level window list and return that.
.. seealso:: :meth:`SetTopWindow`
.. method:: GetUseBestVisual(self)
Returns ``True`` if the application will use the best visual on systems that support different visuals, ``False`` otherwise.
:rtype: `bool`
.. seealso:: :meth:`SetUseBestVisual`
.. method:: IsActive(self)
Returns ``True`` if the application is active, i.e. if one of its windows is currently in the foreground.
If this function returns ``False`` and you need to attract users attention to the application, you may use :meth:`wx.TopLevelWindow.RequestUserAttention` to do it.
:rtype: `bool`
.. staticmethod:: IsDisplayAvailable()
Returns True if the application is able to connect to the system's
display, or whatever the equivallent is for the platform.
:rtype: `bool`
.. method:: MacHideApp(self)
Hide all application windows just as the user can do with the
system Hide command. Mac only.
.. method:: MacNewFile(self)
Called in response of an "open-application" Apple event.
Override this to create a new document in your app.
.. availability:: Only available for OSX.
.. method:: MacOpenFile(self, fileName)
Called in response of an "open-document" Apple event.
:param `fileName`:
:type `fileName`: string
.. wxdeprecated::
This function is kept mostly for backwards compatibility. Please override :meth:`wx.App.MacOpenFiles` method instead in any new code.
.. availability:: Only available for OSX.
.. method:: MacOpenFiles(self, fileNames)
Called in response of an openFiles message with Cocoa, or an "open-document" Apple event with Carbon.
You need to override this method in order to open one or more document files after the user double clicked on it or if the files and/or folders were dropped on either the application in the dock or the application icon in Finder.
By default this method calls MacOpenFile for each file/folder.
:param `fileNames`:
:type `fileNames`: list of strings
.. versionadded:: 2.9.3
.. availability:: Only available for OSX.
.. method:: MacOpenURL(self, url)
Called in response of a "get-url" Apple event.
:param `url`:
:type `url`: string
.. availability:: Only available for OSX.
.. method:: MacPrintFile(self, fileName)
Called in response of a "print-document" Apple event.
:param `fileName`:
:type `fileName`: string
.. availability:: Only available for OSX.
.. method:: MacReopenApp(self)
Called in response of a "reopen-application" Apple event.
.. availability:: Only available for OSX.
.. method:: OSXIsGUIApplication(self)
May be overridden to indicate that the application is not a foreground GUI application under OS X.
This method is called during the application startup and returns ``True`` by default. In this case, wxWidgets ensures that the application is ran as a foreground, GUI application so that the user can interact with it normally, even if it is not bundled. If this is undesired, i.e. if the application doesn't need to be brought to the foreground, this method can be overridden to return ``False``.
Notice that overriding it doesn't make any difference for the bundled applications which are always foreground unless ``LSBackgroundOnly`` key is specified in the ``Info.plist`` file.
:rtype: `bool`
.. versionadded:: 3.0.1
.. availability:: Only available for OSX.
.. method:: SafeYield(self, win, onlyIfNeeded)
This function is similar to :ref:`wx.Yield`, except that it disables the user input to all program windows before calling :meth:`wx.AppConsole.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 :meth:`wx.AppConsole.Yield` .
:param `win`:
:type `win`: wx.Window
:param `onlyIfNeeded`:
:type `onlyIfNeeded`: bool
:rtype: `bool`
.. seealso:: :ref:`wx.SafeYield`
.. method:: SafeYieldFor(self, win, eventsToProcess)
Works like :ref:`wx.SafeYield` with `onlyIfNeeded` == ``True`` except that it allows the caller to specify a mask of events to be processed.
See `AppConsole.YieldFor` for more info.
:param `win`:
:type `win`: wx.Window
:param `eventsToProcess`:
:type `eventsToProcess`: long
:rtype: `bool`
.. method:: SetAssertMode(self, AppAssertMode)
Set the mode indicating how the application responds to assertion
statements. Valid settings are a combination of these flags:
- wx.``wx.APP_ASSERT_SUPPRESS``
- wx.``wx.APP_ASSERT_EXCEPTION``
- wx.``wx.APP_ASSERT_DIALOG``
- wx.``wx.APP_ASSERT_LOG``
The default behavior is to raise a wx.wxAssertionError exception.
:param `wxAppAssertMode`:
:type `wxAppAssertMode`: wx.AppAssertMode
.. method:: SetDisplayMode(self, info)
Set display mode to use.
This is only used in framebuffer wxWidgets ports such as wxDFB.
:param `info`:
:type `info`: wx.VideoMode
:rtype: `bool`
.. method:: SetExitOnFrameDelete(self, flag)
Allows the programmer to specify whether the application will exit when the top-level frame is deleted.
:param `flag`: If ``True`` (the default), the application will exit when the top-level frame is deleted. If ``False``, the application will continue to run.
:type `flag`: bool
.. seealso:: :meth:`GetExitOnFrameDelete` , :ref:`Application Shutdown <application shutdown>`
.. method:: SetNativeTheme(self, theme)
Allows runtime switching of the UI environment theme.
Currently implemented for GTK2-only. Return ``True`` if theme was successfully changed.
:param `theme`: The name of the new theme or an absolute path to a gtkrc-theme-file
:type `theme`: string
:rtype: `bool`
.. method:: SetTopWindow(self, window)
Sets the 'top' window.
You can call this from within :meth:`OnInit` to let wxWidgets know which is the main window. You don't have to set the top window; it is only a convenience so that (for example) certain dialogs without parents can use a specific window as the top window.
If no top window is specified by the application, wxWidgets just uses the first frame or dialog (or better, any :ref:`wx.TopLevelWindow`) in its top-level window list, when it needs to use the top window. If you previously called :meth:`SetTopWindow` and now you need to restore this automatic behaviour you can call::
wx.App.SetTopWindow(None)
:param `window`: The new top window.
:type `window`: wx.Window
.. seealso:: :meth:`GetTopWindow` , :meth:`OnInit`
.. method:: SetUseBestVisual(self, flag, forceTrueColour=False)
Allows the programmer to specify whether the application will use the best visual on systems that support several visual on the same display.
This is typically the case under Solaris and ``IRIX``, where the default visual is only 8-bit whereas certain applications are supposed to run in TrueColour mode.
Note that this function has to be called in the constructor of the :ref:`wx.App` instance and won't have any effect when called later on. This function currently only has effect under GTK.
:param `flag`: If ``True``, the app will use the best visual.
:type `flag`: bool
:param `forceTrueColour`: If ``True`` then the application will try to force using a TrueColour visual and abort the app if none is found.
:type `forceTrueColour`: bool
.. attribute:: AssertMode
See :meth:`~wx.PyApp.GetAssertMode` and :meth:`~wx.PyApp.SetAssertMode`
.. attribute:: DisplayMode
See :meth:`~wx.PyApp.GetDisplayMode` and :meth:`~wx.PyApp.SetDisplayMode`
.. attribute:: ExitOnFrameDelete
See :meth:`~wx.PyApp.GetExitOnFrameDelete` and :meth:`~wx.PyApp.SetExitOnFrameDelete`
.. attribute:: LayoutDirection
See :meth:`~wx.PyApp.GetLayoutDirection`
.. attribute:: TopWindow
See :meth:`~wx.PyApp.GetTopWindow` and :meth:`~wx.PyApp.SetTopWindow`
.. attribute:: UseBestVisual
See :meth:`~wx.PyApp.GetUseBestVisual` and :meth:`~wx.PyApp.SetUseBestVisual`
|