Call the specified function after the current and pending event
handlers have been completed. This is also good for making GUI
method calls from non-GUI threads. Any extra positional or
keyword args are passed on to the callable when it is called.

In the overloaded versions of this function, if flags parameter contains EXEC_ASYNC flag (the default), flow of control immediately returns. If it contains EXEC_SYNC , the current application waits until the other program has terminated.

In the case of synchronous execution, the return value is the exit code of the process (which terminates by the moment the function returns) and will be -1 if the process couldn’t be started and typically 0 if the process terminated successfully. Also, while waiting for the process to terminate, wx.Execute will call wx.Yield . Because of this, by default this function disables all application windows to avoid unexpected reentrancies which could result from the users interaction with the program while the child process is running. If you are sure that it is safe to not disable the program windows, you may pass EXEC_NODISABLE flag to prevent this automatic disabling from happening.

For asynchronous execution, however, the return value is the process id and zero value indicates that the command could not be executed. As an added complication, the return value of -1 in this case indicates that we didn’t launch a new process, but connected to the running one (this can only happen when using DDE under Windows for command execution). In particular, in this case only, the calling code will not get the notification about process termination.

If callback isn’t None and if execution is asynchronous, wx.Process.OnTerminate will be called when the process finishes. Specifying this parameter also allows you to redirect the standard input and/or output of the process being launched by calling wx.Process.Redirect .

Under Windows, when launching a console process its console is shown by default but hidden if its IO is redirected. Both of these default behaviours may be overridden: if EXEC_HIDE_CONSOLE is specified, the console will never be shown. If EXEC_SHOW_CONSOLE is used, the console will be shown even if the child process IO is redirected. Neither of these flags affect non-console Windows applications or does anything under the other systems.

Under Unix the flag EXEC_MAKE_GROUP_LEADER may be used to ensure that the new process is a group leader (this will create a new session if needed). Calling wx.Kill passing wx.KILL_CHILDREN will kill this process as well as all of its children (except those which have started their own session). Under MSW, this flag can be used with console processes only and corresponds to the native CREATE_NEW_PROCESS_GROUP flag.

The EXEC_NOEVENTS flag prevents processing of any events from taking place while the child process is running. It should be only used for very short-lived processes as otherwise the application windows risk becoming unresponsive from the users point of view. As this flag only makes sense with EXEC_SYNC , EXEC_BLOCK equal to the sum of both of these flags is provided as a convenience.

Parameters:

command (string) – The command to execute and any parameters to pass to it as a single string, i.e. “emacs file.txt”.

flags (int) – Must include either wx.EXEC_ASYNC or wx.EXEC_SYNC and can also include wx.EXEC_SHOW_CONSOLE, wx.EXEC_HIDE_CONSOLE, wx.EXEC_MAKE_GROUP_LEADER (in either case) or wx.EXEC_NODISABLE and wx.EXEC_NOEVENTS or wx.EXEC_BLOCK, which is equal to their combination, in wx.EXEC_SYNC case.

env (ExecuteEnv) – An optional pointer to additional parameters for the child process, such as its initial working directory and environment variables. This parameter is available in wxWidgets 2.9.2 and later only.

In Windows, this is the common file selector dialog. In X, this is a file selector box with the same functionality. The path and filename are distinct elements of a full file pathname. If path is empty, the current directory will be used. If filename is empty, no default filename will be supplied. The wildcard determines what files are displayed in the file selector, and file extension supplies a type extension for the required filename. Flags may be a combination of wx.FD_OPEN, wx.FD_SAVE, wx.FD_OVERWRITE_PROMPT or wx.FD_FILE_MUST_EXIST.

Both the Unix and Windows versions implement a wildcard filter. Typing a filename containing wildcards (, ?) in the filename text item, and clicking on Ok, will result in only those files matching the pattern being displayed.

The wildcard may be a specification for multiple types of file with a description for each, such as:

wildcard="BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"

The application must check for an empty return value (the user pressed Cancel). For example:

filename=wx.FileSelector("Choose a file to open")iffilename.strip():# work with the fileprintfilename# else: cancelled by user

Find the first window in the application with the given id. If parent
is None, the search will start from all top-level frames and dialog
boxes; if non-None, the search will be limited to the given window
hierarchy. The search is recursive in both cases.

Find a window by its label. Depending on the type of window, the label may be a window title or panel item label. If parent is None, the search will start from all top-level frames and dialog boxes; if not None, the search will be limited to the given window hierarchy. The search is recursive in both cases.

Find a window by its name (as given in a window constructor or Create function call). If parent is None, the search will start from all top-level frames and dialog boxes; if not None, the search will be limited to the given window hierarchy. The search is recursive in both cases.

For togglable keys (Caps Lock, Num Lock and Scroll Lock), returns True if the key is toggled such that its LED indicator is lit. There is currently no way to test whether togglable keys are up or down.

Even though there are virtual key codes defined for mouse buttons, they cannot be used with this function currently.

In wxGTK, this function can be only used with modifier keys ( WXK_ALT , WXK_CONTROL and WXK_SHIFT ) when not using X11 backend currently.

Returns a wx.MouseState instance that contains the current position of the mouse pointer in screen coordinates, as well as boolean values indicating the up/down status of the mouse buttons and the modifier keys.

The dialogs title is set to caption , it contains a (possibly) multiline message above the single line prompt and the zone for entering the number.

The number entered must be in the range min to max (both of which should be positive) and value is the initial value of it. If the user enters an invalid value, it is forced to fall into the specified range. If the user cancels the dialog, the function returns -1. If it is important to distinguish between cancelling the dialog and actually entering -1 in it, i.e. if -1 is a valid input value, this convenience function can’t be used and wx.NumberEntryDialog should be used directly instead.

Dialog is centered on its parent unless an explicit position is given in pos .

Gets the version and the operating system ID for currently running OS.

The returned OperatingSystemId value can be used for a basic categorization of the OS family; the major and minor version numbers allows to detect a specific system.

For Unix-like systems ( OS_UNIX ) the major and minor version integers will contain the kernel major and minor version numbers (as returned by the ‘uname -r’ command); e.g. “2” and “6” if the machine is using kernel 2.6.19.

For Mac OS X systems ( OS_MAC ) the major and minor version integers are the natural version numbers associated with the OS; e.g. “10” and “6” if the machine is using Mac OS X Snow Leopard.

For Windows-like systems ( OS_WINDOWS ) the major and minor version integers will contain the following values:

Pops up a dialog box containing a message, OK/Cancel buttons and a single-selection listbox.

The user may choose an item and press wx.OK to return a string or Cancel to return the empty string. Use wx.GetSingleChoiceIndex if empty string is a valid choice and if you want to be able to detect pressing Cancel reliably.

You may pass the list of strings to choose from either using choices which is an array of n strings for the listbox or by using a single aChoices parameter of type list of strings .

If centre is True, the message text (which may include new line characters) is centred; if False, the message is left-justified.

Pop up a dialog box with title set to caption, message , and a default_value .

The user may type in text and press wx.OK to return this text, or press Cancel to return the empty string.

If centre is True, the message text (which may include new line characters) is centred; if False, the message is left-justified.

This function is a wrapper around wx.TextEntryDialog and while it is usually more convenient to use, using the dialog directly is more flexible, e.g. it allows you to specify the TE_MULTILINE to allow the user enter multiple lines of text while this function is limited to single line entry only.

This function returns the translation of string in the current locale() .

If the string is not found in any of the loaded message catalogs (see Internationalization ), the original string is returned. In debug build, an error message is logged domain is specified then only that domain/catalog is searched for a matching string. As this function is used very often, an alternative (and also common in Unix world) syntax is provided: the wx._ macro is defined to do the same thing as wx.GetTranslation .

This function is thread-safe.

Parameters:

string (string) –

domain (string) –

Return type:

string

Note

This function is not suitable for literal strings in Unicode builds since the literal strings must be enclosed in T macro which makes them unrecognised by xgettext , and so they are not extracted to the message catalog. Instead, use the wx._ and PLURAL macro for all literal strings.

This is an overloaded version of wx.GetTranslation , please see its documentation for general information.

This version is used when retrieving translation of string that has different singular and plural forms in English or different plural forms in some other language. Like wx.GetTranslation , the string parameter must contain the singular form of the string to be converted and is used as the key for the search in the catalog. The plural parameter is the plural form (in English). The parameter n is used to determine the plural form. If no message catalog is found, string is returned if “n == 1”, otherwise plural is returned.

This function returns the “user id” also known as “login name” under Unix (i.e.

something like “jsmith”). It uniquely identifies the current user (on this system). Under Windows or NT, this function first looks in the environment variables USER and LOGNAME; if neither of these is found, the entry UserId in the wxWidgets section of the WIN.INI file is tried.

This function returns the full user name (something like “Mr. John Smith”).

Under Windows or NT, this function looks for the entry UserName in the wxWidgets section of the WIN.INI file. If PenWindows is running, the entry Current in the section User of the PENWIN.INI file is used.

If doIt is True, the fatal exceptions (also known as general protection faults under Windows or segmentation violations in the Unix world) will be caught and passed to wx.App.OnFatalException .

By default, i.e. before this function is called, they will be handled in the normal way which usually just means that the application will be terminated. Calling wx.HandleFatalExceptions with doIt equal to False will restore this default behaviour.

Notice that this function is only available if USE_ON_FATAL_EXCEPTION is 1 and under Windows platform this requires a compiler with support for SEH (structured exception handling) which currently means only Microsoft Visual C++ or a recent Borland C++ version.

Creates a Image from the data in dataBuffer. The dataBuffer
parameter must be a Python object that implements the buffer interface,
such as a string, array, etc. The dataBuffer object is expected to
contain a series of RGB bytes and be width*height*3 bytes long. A buffer
object can optionally be supplied for the image’s alpha channel data, and
it is expected to be width*height bytes long.

The Image will be created with its data and alpha pointers initialized
to the memory address pointed to by the buffer objects, thus saving the
time needed to copy the image data from the buffer object to the Image.
While this has advantages, it also has the shoot-yourself-in-the-foot
risks associated with sharing a C pointer between two objects.

To help alleviate the risk a reference to the data and alpha buffer
objects are kept with the Image, so that they won’t get deleted until
after the wx.Image is deleted. However please be aware that it is not
guaranteed that an object won’t move its memory buffer to a new location
when it needs to resize its contents. If that happens then the Image
will end up referring to an invalid memory location and could cause the
application to crash. Therefore care should be taken to not manipulate
the objects used for the data and alpha buffers in a way that would cause
them to change size.

This function calls wx.Image.AddHandler for all the available image handlers (see Available image handlers for the full list). Calling it is the simplest way to initialize wx.Image but it creates and registers even the handlers your program may not use. If you want to avoid the overhead of doing this you need to call wx.Image.AddHandler manually just for the handlers that you do want to use.

Returns True if the operating system the program is running under is 64 bit.

The check is performed at run-time and may differ from the value available at compile-time (at compile-time you can just check if sizeof(void*)==8 ) since the program could be running in emulation mode or in a mixed 32/64 bit system (bi-architecture operating system).

Return type:

bool

Note

This function is not 100% reliable on some systems given the fact that there isn’t always a standard way to do a reliable check on the OS architecture.

Equivalent to the Unix kill function: send the given signal sig to the process with PIDpid.

The valid signal values are:

# Signal enumeration
wx.SIGNONE # verify if the process exists under Unix
wx.SIGHUP
wx.SIGINT
wx.SIGQUIT
wx.SIGILL
wx.SIGTRAP
wx.SIGABRT
wx.SIGEMT
wx.SIGFPE
wx.SIGKILL # forcefully kill, dangerous!
wx.SIGBUS
wx.SIGSEGV
wx.SIGSYS
wx.SIGPIPE
wx.SIGALRM
wx.SIGTERM # terminate the process gently
``SIGNONE`` , ``SIGKILL`` and ``SIGTERM`` have the same meaning under both Unix and Windows but all the other signals are equivalent to ``SIGTERM`` under Windows. Moreover, under Windows, ``SIGTERM`` is implemented by posting a message to the application window, so it only works if the application does have windows. If it doesn't, as is notably always the case for the console applications, you need to use ``SIGKILL`` to actually kill the process. Of course, this doesn't allow the process to shut down gracefully and so should be avoided if possible.

Returns 0 on success, -1 on failure. If the rc parameter is not None, it will be filled with a value from the KillError enum:

# KillError enumerationwx.KILL_OK# no errorwx.KILL_BAD_SIGNAL# no such signalwx.KILL_ACCESS_DENIED# permission deniedwx.KILL_NO_PROCESS# no such processwx.KILL_ERROR# another, unspecified error

The flags parameter can be wx.KILL_NOCHILDREN (the default), or wx.KILL_CHILDREN, in which case the child processes of this process will be killed too. Note that under Unix, for wx.KILL_CHILDREN to work you should have created the process by passing wx.EXEC_MAKE_GROUP_LEADER to wx.Execute .

If the flags parameter contains BROWSER_NEW_WINDOW flag, a new window is opened for the URL (currently this is only supported under Windows).

And unless the flags parameter contains BROWSER_NOBUSYCURSOR flag, a busy cursor is shown while the browser is being launched (using wx.BusyCursor).

The parameter url is interpreted as follows:

if it has a valid scheme (e.g. "file:" , "http:" or "mailto:" ) it is passed to the appropriate browser configured in the user system.

if it has no valid scheme (e.g. it’s a local file path without the "file:" prefix), then FileExists and DirExists are used to test if it’s a local file/directory; if it is, then the browser is called with the url parameter eventually prefixed by "file:" .

if it has no valid scheme and it’s not a local file/directory, then "http:" is prepended and the browser is called.

Returns True if the application was successfully launched.

Parameters:

url (string) –

flags (int) –

Return type:

bool

Note

For some configurations of the running user, the application which is launched to open the given URL may be URL-dependent (e.g. a browser may be used for local URLs while another one may be used for remote URLs).

Mostly used by wxWidgets itself, but might be handy for logging errors after system call (API function) failure.

It logs the specified message text as well as the last system error code (errno or GetLastError() depending on the platform) and the corresponding error message. The second form of this function takes the error code explicitly as the first argument.

This is a convenient function which is usually used instead of using wx.MessageDialog directly. Notice however that some of the features, such as extended text and custom labels for the message box buttons, are not provided by this function but only by wx.MessageDialog.

The return value is one of: YES , NO , CANCEL , OK or HELP (notice that this return value is different from the return value of wx.MessageDialog.ShowModal ).

The microsecond resolution may not, in fact, be available on all platforms (currently only Unix platforms with nanosleep(2) may provide it) in which case this is the same as calling wx.MilliSleep with the argument of microseconds/1000.

IDs generated by this function can possibly conflict with IDs used elsewhere in the application code. It is recommended to instead use the wx.ID_ANYID to assign generated IDs for the controls menu items and etc. that you create in the application. These IDs are guaranteed to not conflict with the other IDs that are in use in the application. For those cases where you need to create an ID that can be used more than once then please see wx.NewIdRef.

Reserves a new Window ID (or range of WindowIDs) and returns a
wx.WindowIDRef object (or list of them) that will help
manage the reservation of that ID.

This function is intended to be a drop-in replacement of the old
and deprecated wx.NewId function, with the added benefit
that the ID should never conflict with an in-use ID or other IDs
generated by this function.

This function shows a message to the user in a safe way and should be safe to call even before the application has been initialized or if it is currently in some other strange state (for example, about to crash).

Under Windows this function shows a message box using a native dialog instead of wx.MessageBox (which might be unsafe to call), elsewhere it simply prints the message to the standard output using the title as prefix.

Parameters:

title (string) – The title of the message box shown to the user or the prefix of the message string.

This function shuts down or reboots the computer depending on the value of the flags.

Parameters:

flags (int) – One of SHUTDOWN_POWEROFF , SHUTDOWN_REBOOT or SHUTDOWN_LOGOFF (currently implemented only for MSW) possibly combined with SHUTDOWN_FORCE which forces shutdown under MSW by forcefully terminating all the applications. As doing this can result in a data loss, this flag shouldn’t be used unless really necessary.

Return type:

bool

Returns:

True on success, False if an error occurred.

Note

Note that performing the shutdown requires the corresponding access rights (superuser under Unix, SE_SHUTDOWN privilege under Windows NT) and that this function is only implemented under Unix and MSW.

By default, the functions strips both the mnemonics character ( '&' ) which is used to indicate a keyboard shortkey, and the accelerators, which are used only in the menu items and are separated from the main text by the \t (TAB) character. By using flags of Strip_Mnemonics or Strip_Accel to strip only the former or the latter part, respectively.

This function is deprecated because its name is misleading: notice that the argument is in milliseconds, not microseconds. Please use either wx.MilliSleep or wx.MicroSleep depending on the resolution you need.

This function wakes up the (internal and platform dependent) idle system, i.e.

it will force the system to send an idle event even if the system currently is idle and thus would not send any idle event until after some other event would get sent. This is also useful for sending events between two threads and is used by the corresponding functions wx.PostEvent and wx.EvtHandler.AddPendingEvent .