Table Of Contents

Previous topic

PropagationDisabler

Next topic

PyEventBinder

This Page

phoenix_title PyApp

The App class represents the application itself when USE_GUI=1 .

In addition to the features provided by AppConsole it keeps track of the top window (see SetTopWindow) and adds support for video modes (see SetVideoMode()).

In general, application-wide settings for GUI-only apps are accessible from App (or from SystemSettings or SystemOptions classes).

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 CloseEvent.
  • EVT_END_SESSION: Process an end session event, supplying the member function. See CloseEvent.
  • EVT_ACTIVATE_APP: Process a wxEVT_ACTIVATE_APP event. See ActivateEvent.
  • EVT_HIBERNATE: Process a hibernate event. See ActivateEvent.
  • EVT_DIALUP_CONNECTED: A connection with the network was established. See DialUpEvent.
  • EVT_DIALUP_DISCONNECTED: The connection with the network was lost. See DialUpEvent.
  • EVT_IDLE: Process a wxEVT_IDLE event. See IdleEvent.

class_hierarchy Inheritance Diagram

Inheritance diagram for class PyApp

Inheritance diagram of PyApp


method_summary Methods Summary

__init__ Constructor.
GetAssertMode Returns the current mode for how the application responds to asserts.
GetDisplayMode Get display mode that is used use.
GetExitOnFrameDelete Returns True if the application will exit when the top-level frame is deleted.
GetLayoutDirection Return the layout direction for the current locale or Layout_Default if it’s unknown.
GetTopWindow Returns a pointer to the top window.
GetUseBestVisual Returns True if the application will use the best visual on systems that support different visuals, False otherwise.
IsActive Returns True if the application is active, i.e.
IsDisplayAvailable Returns True if the application is able to connect to the system’s
MacHideApp Hide all application windows just as the user can do with the
MacNewFile Called in response of an “open-application” Apple event.
MacOpenFile Called in response of an “open-document” Apple event.
MacOpenFiles Called in response of an openFiles message with Cocoa, or an “open-document” Apple event with Carbon.
MacOpenURL Called in response of a “get-url” Apple event.
MacPrintFile Called in response of a “print-document” Apple event.
MacReopenApp Called in response of a “reopen-application” Apple event.
SafeYield This function is similar to Yield, except that it disables the user input to all program windows before calling AppConsole.Yield and re-enables it again afterwards.
SafeYieldFor Works like SafeYield with onlyIfNeeded == True except that it allows the caller to specify a mask of events to be processed.
SetAssertMode Set the mode indicating how the application responds to assertion
SetDisplayMode Set display mode to use.
SetExitOnFrameDelete Allows the programmer to specify whether the application will exit when the top-level frame is deleted.
SetNativeTheme Allows runtime switching of the UI environment theme.
SetTopWindow Sets the ‘top’ window.
SetUseBestVisual Allows the programmer to specify whether the application will use the best visual on systems that support several visual on the same display.

api Class API



class PyApp(AppConsole)

The App class represents the application itself when USE_GUI=1.

Possible constructors:

PyApp()

Methods



__init__(self)

Constructor.

Called implicitly with a definition of a App object.



GetAssertMode(self)

Returns the current mode for how the application responds to asserts.

Return type: AppAssertMode


GetDisplayMode(self)

Get display mode that is used use.

This is only used in framebuffer wxWidgets ports such as wxDFB.

Return type: VideoMode


GetExitOnFrameDelete(self)

Returns True if the application will exit when the top-level frame is deleted.

Return type:bool


GetLayoutDirection(self)

Return the layout direction for the current locale or Layout_Default if it’s unknown.

Return type: LayoutDirection


GetTopWindow(self)

Returns a pointer to the top window.

Return type: Window

Note

If the top window hasn’t been set using SetTopWindow , this function will find the first top-level window (frame or dialog or instance of TopLevelWindow) from the internal top level window list and return that.

See also

SetTopWindow



GetUseBestVisual(self)

Returns True if the application will use the best visual on systems that support different visuals, False otherwise.

Return type:bool

See also

SetUseBestVisual



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 TopLevelWindow.RequestUserAttention to do it.

Return type:bool


static IsDisplayAvailable()
Returns True if the application is able to connect to the system’s display, or whatever the equivallent is for the platform.
Return type:bool


MacHideApp(self)

Hide all application windows just as the user can do with the system Hide command. Mac only.



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.



MacOpenFile(self, fileName)

Called in response of an “open-document” Apple event.

Parameters:fileName (string) –

Deprecated since version 2.9.4: This function is kept mostly for backwards compatibility. Please override App.MacOpenFiles method instead in any new code.

Availability

Only available for OSX.



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 float 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.

Parameters:fileNames (list of strings) –

New in version 2.9.3.

Availability

Only available for OSX.



MacOpenURL(self, url)

Called in response of a “get-url” Apple event.

Parameters:url (string) –

Availability

Only available for OSX.



MacPrintFile(self, fileName)

Called in response of a “print-document” Apple event.

Parameters:fileName (string) –

Availability

Only available for OSX.



MacReopenApp(self)

Called in response of a “reopen-application” Apple event.

Availability

Only available for OSX.



SafeYield(self, win, onlyIfNeeded)

This function is similar to Yield, except that it disables the user input to all program windows before calling 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 AppConsole.Yield .

Parameters:
  • win (Window) –
  • onlyIfNeeded (bool) –
Return type:

bool

See also

SafeYield



SafeYieldFor(self, win, eventsToProcess)

Works like 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.

Parameters:
  • win (Window) –
  • eventsToProcess (long) –
Return type:

bool



SetAssertMode(self, AppAssertMode)

Set the mode indicating how the application responds to assertion statements. Valid settings are a combination of these flags:

  • APP_ASSERT_SUPPRESS
  • APP_ASSERT_EXCEPTION
  • APP_ASSERT_DIALOG
  • APP_ASSERT_LOG

The default behavior is to raise a wx.wxAssertionError exception.

Parameters:wxAppAssertMode (AppAssertMode) –


SetDisplayMode(self, info)

Set display mode to use.

This is only used in framebuffer wxWidgets ports such as wxDFB.

Parameters:info (VideoMode) –
Return type:bool


SetExitOnFrameDelete(self, flag)

Allows the programmer to specify whether the application will exit when the top-level frame is deleted.

Parameters:flag (bool) – If True (the default), the application will exit when the top-level frame is deleted. If False, the application will continue to run.


SetNativeTheme(self, theme)

Allows runtime switching of the UI environment theme.

Currently implemented for GTK2-only. Return True if theme was successfully changed.

Parameters:theme (string) – The name of the new theme or an absolute path to a gtkrc-theme-file
Return type:bool


SetTopWindow(self, window)

Sets the ‘top’ window.

You can call this from within 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 TopLevelWindow) in its top-level window list, when it needs to use the top window. If you previously called SetTopWindow and now you need to restore this automatic behaviour you can call

wx.App.SetTopWindow(None)
Parameters:window (Window) – The new top window.

See also

GetTopWindow , OnInit



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 App instance and won’t have any effect when called later on. This function currently only has effect under GTK.

Parameters:
  • flag (bool) – If True, the app will use the best visual.
  • forceTrueColour (bool) – If True then the application will try to force using a TrueColour visual and abort the app if none is found.

Properties



AssertMode

See GetAssertMode and SetAssertMode



DisplayMode

See GetDisplayMode and SetDisplayMode



ExitOnFrameDelete

See GetExitOnFrameDelete and SetExitOnFrameDelete



LayoutDirection

See GetLayoutDirection



TopWindow

See GetTopWindow and SetTopWindow



UseBestVisual

See GetUseBestVisual and SetUseBestVisual