GeezerVison is showing docs.wxpython.org — wx Functions — wxPython 4.3.2 Docs
wx Functions¶
The functions and macros defined in the wx module are described here: you can look up a function using the alphabetical listing of them.
Functions¶
-
wx.Abort()¶
Exits the program immediately.
This is a simple wrapper for the standard abort() function.
- Return type:
None
-
wx.AutoBufferedPaintDCFactory(window)¶
Check if the window is natively double buffered and will return a wx.PaintDC if it is, a wx.BufferedPaintDC otherwise.
It is the caller’s responsibility to delete the wx.DC pointer when finished with it.
- Parameters:
window (wx.Window)
- Return type:
wx.DC
-
wx.BeginBusyCursor(*args, **kw)¶
Overloaded Implementations:
BeginBusyCursor (cursor=HOURGLASS_CURSOR)
Changes the cursor to the given cursor for all windows in the application.
Use wx.EndBusyCursor to revert the cursor back to its previous state. These two calls can be nested, and a counter ensures that only the outer calls take effect.
Prefer using wx.BusyCursor to using this function directly.
- Parameters:
cursor (wx.Cursor)
- Return type:
None
BeginBusyCursor (cursors)
Overload of wx.BeginBusyCursor taking a cursor bundle.
This overload selects the cursor of the appropriate size from cursors.
As with wx.SetCursor , the busy cursor is currently not updated automatically if the DPI or preferred cursor size changes because this is considered to be unlikely to happen during the brief time while the busy cursor is shown.
- Parameters:
cursors (wx.CursorBundle)
- Return type:
None
Added in version 4.3/wxWidgets-3.3.0.
-
wx.Bell()¶
Ring the system bell.
- Return type:
None
Note
This function is categorized as a GUI one and so is not thread-safe.
-
wx.BitmapFromBuffer(width, height, dataBuffer, alphaBuffer=None)¶
A compatibility wrapper for wx.Bitmap.FromBuffer and wx.Bitmap.FromBufferAndAlpha
-
wx.BitmapFromBufferRGBA(width, height, dataBuffer)¶
A compatibility wrapper for wx.Bitmap.FromBufferRGBA
-
wx.BitmapFromImage(image)¶
A compatibility wrapper for the wx.Bitmap(wx.Image) constructor
-
wx.CallAfter(callableObj: Callable[_P, _T], *args: _P.args, **kw: _P.kwargs)¶
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.
- Parameters:
callableObj (PyObject) – the callable object
args – arguments to be passed to the callable object
kw – keywords to be passed to the callable object
-
wx.CheckOsVersion(majorVsn, minorVsn=0, microVsn=0)¶
Returns True if the version of the operating system on which the program is running under is the same or later than the given version.
For Unix-like systems (except macOS), this is the kernel version, not the marketing/distribution version.
- Parameters:
majorVsn (int)
minorVsn (int)
microVsn (int)
- Return type:
bool
Added in version 4.1/wxWidgets-3.1.0.
-
wx.ClientDisplayRect()¶
Returns the dimensions of the work area on the display.
This is the same as wx.GetClientDisplayRect but allows retrieving the individual components instead of the entire rectangle.
Any of the output pointers can be nullptr if the corresponding value is not needed by the caller.
- Return type:
Tuple[int, int, int, int]
-
wx.ColourDisplay()¶
Returns True if the display is colour, False otherwise.
- Return type:
bool
Note
Use of this function is not recommended in the new code as it only works for the primary display. Use wx.Display.GetDepth to retrieve the depth of the appropriate display and compare it with 1 instead.
-
wx.date2pydate(date)¶
Convert a DateTime object to a Python datetime.
-
wx.DateTimeFromDMY(day, month, year=DateTime.Inv_Year, hour=0, minute=0, second=0, millisecond=0)¶
Compatibility wrapper for DateTime.FromDMY
-
wx.DateTimeFromHMS(hour, minute=0, second=0, millisecond=0)¶
Compatibility wrapper for DateTime.FromHMS
-
wx.DateTimeFromJDN(jdn)¶
Compatibility wrapper for DateTime.FromJDN
-
wx.DateTimeFromTimeT(timet)¶
Compatibility wrapper for DateTime.FromTimeT
-
wx.DecToHex(*args, **kw)¶
Overloaded Implementations:
DecToHex (dec, buf)
Convert decimal integer to 2-character hexadecimal string.
- Parameters:
dec (int) – A number to be converted.
buf (wx.Char) – A pointer to the buffer that receives hexadecimal string (not prefixed by 0x ). This buffer should be large enough to hold at least 3 characters: 2 hexadecimal digits and the terminating null character.
- Return type:
None
Note
Returned string is composed of uppercase hexadecimal characters.
DecToHex (dec)
Convert decimal integer to 2-character hexadecimal string.
- Parameters:
dec (int) – A number to be converted.
- Return type:
str
- Returns:
String containing hexadecimal string, not prefixed by 0x , composed of uppercase characters.
DecToHex (dec, ch1, ch2)
Returns 2 characters of hexadecimal representation of a given number.
- Parameters:
dec (int) – A number to be converted.
ch1 (int) – Pointer to the variable that receives 1st hexadecimal character. It must not be nullptr.
ch2 (int) – Pointer to the variable that receives 2nd hexadecimal character. It must not be nullptr.
- Return type:
None
Note
Returned characters are uppercase.
-
wx.DirSelector(message=DirSelectorPromptStr, defaultPath='', style=DD_DEFAULT_STYLE, pos=DefaultPosition, parent=None)¶
Pops up a directory selector dialog.
The arguments have the same meaning as those of DirDialog.__init__ . The message is displayed at the top, and the defaultPath, if specified, is set as the initial selection.
The application must check for an empty return value (if the user pressed Cancel). For example:
selector = wx.DirSelector("Choose a folder")
if selector.strip():
# Do something with the folder name
print selector
- Parameters:
-
- Return type:
str
-
wx.DisableAsserts()¶
Disable the condition checks in the assertions.
This is the same as calling wx.SetAssertHandler with nullptr handler.
- Return type:
None
-
wx.DisplayDepth()¶
Returns the depth of the display (a value of 1 denotes a monochrome display).
- Return type:
int
Note
Use of this function is not recommended in the new code as it only works for the primary display. Use wx.Display.GetDepth to retrieve the depth of the appropriate display instead.
-
wx.DisplaySize()¶
Returns the display size in pixels.
Either of output pointers can be nullptr if the caller is not interested in the corresponding value.
- Return type:
Tuple[int, int]
Note
Use of this function is not recommended in the new code as it only works for the primary display. Use wx.Display.GetGeometry to retrieve the size of the appropriate display instead.
-
wx.DisplaySizeMM()¶
Returns the display size in millimeters.
Either of output pointers can be nullptr if the caller is not interested in the corresponding value.
- Return type:
Tuple[int, int]
-
wx.DumpWindow(window)¶
Return a string with human-readable platform-specific description of the window useful for diagnostic purposes.
The string returned from this function doesn’t have any fixed form and can vary between different wxWidgets ports and versions, but contains some useful description of the window and uniquely identifies it. This can be useful to include in debug or tracing messages.
- Parameters:
window (wx.Window) – Window pointer which is allowed to be nullptr.
- Return type:
str
Added in version 4.1/wxWidgets-3.1.6.
-
wx.EmptyBitmap(width, height, depth=BITMAP_SCREEN_DEPTH)¶
A compatibility wrapper for the wx.Bitmap(width, height, depth) constructor
-
wx.EmptyBitmapRGBA(width, height, red=0, green=0, blue=0, alpha=0)¶
A compatibility wrapper for wx.Bitmap.FromRGBA
-
wx.EmptyIcon()¶
A compatibility wrapper for the Icon constructor
-
wx.EmptyImage(width=0, height=0, clear=True)¶
A compatibility wrapper for the wx.Image(width, height) constructor
-
wx.EnableTopLevelWindows(enable=True)¶
This function enables or disables all top level windows.
It is used by wx.SafeYield .
- Parameters:
enable (bool)
- Return type:
None
-
wx.EndBusyCursor()¶
Changes the cursor back to the original cursor, for all windows in the application.
Use with wx.BeginBusyCursor .
- Return type:
None
-
wx.Execute(command, flags=EXEC_ASYNC, callback=None, env=None)¶
Executes another program in Unix or Windows.
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 nullptr 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.
callback (wx.Process) – An optional pointer to wx.Process.
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.
- Return type:
int
-
wx.Exit()¶
Exits application after calling wx.App.OnExit .
Should only be used in an emergency: normally the top-level frame should be deleted (after deleting all other frames) to terminate the application. See wx.CloseEvent and wx.App.
- Return type:
None
-
wx.FFont(pointSize, family, flags=FONTFLAG_DEFAULT, faceName='', encoding=FONTENCODING_DEFAULT)¶
- Return type:
wx.Font
-
wx.FileSelector(message, default_path='', default_filename='', default_extension='', wildcard=FileSelectorDefaultWildcardStr, flags=0, parent=None, x=DefaultCoord, y=DefaultCoord)¶
Pops up a file selector box.
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 FD_OPEN , FD_SAVE , FD_OVERWRITE_PROMPT or 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")
if filename.strip():
# work with the file
print filename
# else: cancelled by user
- Parameters:
-
- Return type:
str
Note
FD_MULTIPLE can only be used with wx.FileDialog and not here since this function only returns a single file name.
-
wx.FileSelectorEx(message=FileSelectorPromptStr, default_path='', default_filename='', indexDefaultExtension=None, wildcard=FileSelectorDefaultWildcardStr, flags=0, parent=None, x=DefaultCoord, y=DefaultCoord)¶
An extended version of wx.FileSelector
- Parameters:
-
- Return type:
str
-
wx.FindMenuItemId(frame, menuString, itemString)¶
Find a menu item identifier associated with the given frame’s menu bar.
- Parameters:
frame (wx.Frame)
menuString (string)
itemString (string)
- Return type:
int
-
wx.FindWindowAtPoint(pt)¶
Find the deepest window at the given mouse position in screen coordinates, returning the window if found, or nullptr if not.
This function takes child windows at the given position into account even if they are disabled. The hidden children are however skipped by it.
- Parameters:
pt (wx.Point)
- Return type:
wx.Window
-
wx.FindWindowAtPointer()¶
Find the deepest window at the mouse pointer position, returning the window and current pointer position in screen coordinates.
- Return type:
Tuple[Window, Point]
-
wx.FindWindowById(id, parent=None)¶
FindWindowById(id, parent=None) . Window
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.
- Return type:
wx.Window
-
wx.FindWindowByLabel(label, parent=None)¶
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 nullptr, the search will start from all top-level frames and dialog boxes; if non-null, the search will be limited to the given window hierarchy. The search is recursive in both cases.
- Parameters:
-
- Return type:
wx.Window
-
wx.FindWindowByName(name, parent=None)¶
Find a window by its name (as given in a window constructor or Create function call). If parent is nullptr, the search will start from all top-level frames and dialog boxes; if non-null, the search will be limited to the given window hierarchy. The search is recursive in both cases.
If no such named window is found, wx.FindWindowByLabel is called.
- Parameters:
-
- Return type:
wx.Window
-
wx.GetAccelFromString(label)¶
-
wx.GetActiveWindow()¶
Gets the currently active window (implemented for MSW and GTK only currently, always returns nullptr in the other ports).
- Return type:
wx.Window
-
wx.GetApp()¶
Returns the current application object.
- Return type:
wx.AppConsole
-
wx.GetBatteryState()¶
Returns battery state as one of BATTERY_NORMAL_STATE , BATTERY_LOW_STATE , BATTERY_CRITICAL_STATE , BATTERY_SHUTDOWN_STATE or BATTERY_UNKNOWN_STATE .
Currently only implemented on MS Windows; returns BATTERY_UNKNOWN_STATE elsewhere.
- Return type:
wx.BatteryState
-
wx.GetClientDisplayRect()¶
Returns the dimensions of the work area on the display.
On Windows this means the area not covered by the taskbar, etc. Other platforms are currently defaulting to the whole display until a way is found to provide this info for all window managers, etc.
- Return type:
wx.Rect
-
wx.GetColourFromUser(parent=None, colInit=NullColour, caption='', data=None)¶
Shows the colour selection dialog and returns the colour selected by user or invalid colour (use wx.Colour.IsOk to test whether a colour is valid) if the dialog was cancelled.
- Parameters:
parent (wx.Window) – The parent window for the colour selection dialog.
colInit (wx.Colour) – If given, this will be the colour initially selected in the dialog.
caption (string) – If given, this will be used for the dialog caption.
data (wx.ColourData) – Optional object storing additional colour dialog settings, such as custom colours. If none is provided the same settings as the last time are used.
- Return type:
wx.Colour
-
wx.GetCpuArchitectureName()¶
Returns the CPU architecture name.
This can be, for example, “x86_64”, “arm64”, or “i86pc”. The name for the same CPU running on the same hardware can vary across operating systems.
The returned string may be empty if the CPU architecture couldn’t be recognized.
- Return type:
str
Added in version 4.1/wxWidgets-3.1.5.
-
wx.GetDisplayPPI()¶
Returns the display resolution in pixels per inch.
The x component of the returned wx.Size object contains the horizontal resolution and the y one – the vertical resolution.
- Return type:
wx.Size
Note
Use of this function is not recommended in the new code as it only works for the primary display. Use wx.Display.GetPPI to retrieve the resolution of the appropriate display instead.
-
wx.GetDisplaySize()¶
Returns the display size in pixels.
- Return type:
wx.Size
Note
Use of this function is not recommended in the new code as it only works for the primary display. Use wx.Display.GetGeometry to retrieve the size of the appropriate display instead.
-
wx.GetDisplaySizeMM()¶
Returns the display size in millimeters.
- Return type:
wx.Size
-
wx.GetEmailAddress()¶
Copies the user’s email address into the supplied buffer, by concatenating the values returned by wx.GetFullHostName and wx.GetUserId .
- Return type:
str
- Returns:
True if successful, False otherwise.
-
wx.Getenv(*args, **kw)¶
Overloaded Implementations:
Getenv (ws)
- Parameters:
ws (wchar_t)
- Return type:
str
Getenv (s)
- Parameters:
s (string)
- Return type:
str
-
wx.GetFontFromUser(parent=None, fontInit=NullFont, caption='')¶
Shows the font selection dialog and returns the font selected by user or invalid font (use wx.Font.IsOk to test whether a font is valid) if the dialog was cancelled.
- Parameters:
parent (wx.Window) – The parent window for the font selection dialog.
fontInit (wx.Font) – If given, this will be the font initially selected in the dialog.
caption (string) – If given, this will be used for the dialog caption.
- Return type:
wx.Font
-
wx.GetFullHostName()¶
Returns the FQDN (fully qualified domain host name) or an empty string on error.
- Return type:
str
-
wx.GetHomeDir()¶
Return the (current) user’s home directory.
- Return type:
str
-
wx.GetHostName()¶
Copies the current host machine’s name into the supplied buffer.
Please note that the returned name is not fully qualified, i.e. it does not include the domain name.
- Return type:
str
- Returns:
The hostname if successful or an empty string otherwise.
-
wx.GetKeyState(key)¶
For normal keys, returns True if the specified key is currently down.
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.
- Parameters:
key (KeyCode)
- Return type:
bool
-
wx.GetLibraryVersionInfo()¶
Get wxWidgets version information.
- Return type:
wx.VersionInfo
-
wx.GetLocale()¶
Get the current locale object (note that it may be nullptr!)
- Return type:
wx.Locale
-
wx.GetMousePosition()¶
Returns the mouse position in screen coordinates.
- Return type:
wx.Point
-
wx.GetMouseState()¶
Returns the current state of the mouse.
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.
- Return type:
wx.MouseState
-
wx.GetNativeCpuArchitectureName()¶
In some situations the current process and native CPU architecture may be different.
This returns the native CPU architecture regardless of the current process CPU architecture.
Common examples for CPU architecture differences are the following:
Win32 process in x64 Windows (WoW)
Win32 or x64 process on ARM64 Windows (WoW64)
x86_64 process on ARM64 macOS (Rosetta 2)
The returned string may be empty if the CPU architecture couldn’t be recognized.
- Return type:
str
Added in version 4.1/wxWidgets-3.1.6.
-
wx.GetNumberFromUser(message, prompt, caption, value, min=0, max=100, parent=None, pos=DefaultPosition)¶
Shows a dialog asking the user for numeric input.
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 .
- Parameters:
message (string)
prompt (string)
caption (string)
value (long)
min (long)
max (long)
parent (wx.Window)
pos (wx.Point)
- Return type:
int
-
wx.GetOsDescription()¶
Returns the string containing the description of the current platform in a user-readable form.
For example, this function may return strings like “Windows 10 Pro 22H2 (build 19045), 64-bit edition”, “Linux Mint 22.3, based on ubuntu debian (noble), 6.18.36-generic x86_64”, “AlmaLinux 10.1 (Heliotrope Lion), 6.12.0-55.9.1.el10_0.x86_64”, or “Linux 4.1.4 i386”.
- Return type:
str
-
wx.GetOsVersion(micro=None)¶
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, minor, and micro version numbers allows detecting a specific system.
If on Unix-like systems the version can’t be detected all three version numbers will have a value of -1.
On systems where only the micro version can’t be detected or doesn’t make sense, it will have a value of 0.
For Unix-like systems ( OS_UNIX ) the major, minor, and micro version integers will contain the kernel’s major, minor, and micro version numbers (as returned by the ‘uname -r’ command); e.g. “4”, “1”, and “4” if the machine is using kernel 4.1.4.
On Linux ( LINUX defined), if you are interested in the distribution version rather than the kernel version, see wx.GetLinuxDistributionInfo .
For macOS systems ( OS_MAC ) the major and minor version integers are the natural version numbers associated with the OS; e.g. “10”, “11” and “2” if the machine is using macOS El Capitan 10.11.2.
For Windows-like systems ( OS_WINDOWS ) the major, minor and micro (equal to the build number) version integers will contain the following values:
Windows OS name |
Major version |
Minor version |
Build number |
Windows Server 2025 |
10 |
0 |
26100 |
Windows 11 |
10 |
0 |
|
Windows Server 2022 |
10 |
0 |
20348 |
Windows 10 |
10 |
0 |
|
Windows Server 2019 |
10 |
0 |
17763 |
Windows Server 2016 |
10 |
0 |
14393 |
Windows 8.1 |
6 |
3 |
|
Windows Server 2012 R2 |
6 |
3 |
|
Windows 8 |
6 |
2 |
|
Windows Server 2012 |
6 |
2 |
|
Windows 7 |
6 |
1 |
|
Windows 2008 R2 |
6 |
1 |
|
Windows Vista |
6 |
0 |
|
Windows Server 2008 |
6 |
0 |
|
Windows Server 2003 R2 |
5 |
2 |
|
Windows Server 2003 |
5 |
2 |
|
Windows XP |
5 |
1 |
|
See the`Microsoft documentation <https://learn.microsoft.com/en-us/windows/win32/sysinfo/operating-system-version>`_ for more info about the values above.
- Parameters:
micro (int)
- Return type:
Tuple[OperatingSystemId, int, int]
-
wx.GetPasswordFromUser(message, caption=GetPasswordFromUserPromptStr, default_value='', parent=None, x=DefaultCoord, y=DefaultCoord, centre=True)¶
Similar to wx.GetTextFromUser but the text entered in the dialog is not shown on screen but replaced with stars.
This is intended to be used for entering passwords as the function name implies.
The x, y and centre parameters are used in the same way as in wx.GetTextFromUser .
- Parameters:
message (string)
caption (string)
default_value (string)
parent (wx.Window)
x (int)
y (int)
centre (bool)
- Return type:
str
Note
Before wxWidgets 3.3.4, the position was ignored if centre was True, i.e. by default.
-
wx.GetPowerType()¶
Returns the type of power source as one of POWER_SOCKET , POWER_BATTERY or POWER_UNKNOWN .
Currently only implemented on MS Windows; returns POWER_UNKNOWN elsewhere.
- Return type:
wx.PowerType
-
wx.GetProcessId()¶
Returns the number uniquely identifying the current process in the system.
If an error occurs, 0 is returned.
- Return type:
int
-
wx.GetSingleChoice(*args, **kw)¶
Overloaded Implementations:
GetSingleChoice (message, caption, aChoices, parent=None, x=DefaultCoord, y=DefaultCoord, centre=True, width=DefaultCoord, height=DefaultCoord, initialSelection=0)
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 both x and y are specified, i.e. are not DefaultCoord, the dialog is shown at this position and centre is ignored. It is an error to specify only one of them. Otherwise, the dialog is centred on the screen or on its parent window if centre is True (which is the default) or shown at the default position if it is False.
If width and/or height are specified, i.e. are not DefaultCoord, the dialog is made at least this big, but it is never made smaller than the size needed to show all its contents.
GetSingleChoice (message, caption, choices, initialSelection, parent=None)
- Parameters:
-
- Return type:
str
-
wx.GetStockHelpString(id, client=STOCK_MENU)¶
Return help string associated with given stock id and client.
This function uses the default help string shown in the status bar when the item with the given id is selected in a menu, e.g. for ID_EXIT the returned string is “Quit this program”.
- Parameters:
id (wx.WindowID) – The stock item identifier to get the help string for.
client (StockHelpStringClient) – The client context for which the help string is requested, currently can only be STOCK_MENU , which is the default value for this parameter.
- Return type:
str
- Returns:
The translated help string for the given stock item identifier and client context, or an empty string if no default help string is available for this id.
-
wx.GetStockLabel(id, flags=STOCK_WITH_MNEMONIC)¶
Returns label that should be used for given id element.
- Parameters:
-
- Return type:
str
-
wx.GetTextFromUser(*args, **kw)¶
Overloaded Implementations:
GetTextFromUser (message, caption=GetTextFromUserPromptStr, default_value=’’, parent=None, x=DefaultCoord, y=DefaultCoord, centre=True)
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 both x and y are specified, i.e. are not DefaultCoord, the dialog is shown at this position and centre is ignored. It is an error to specify only one of them. Otherwise, the dialog is centred on the screen or on its parent window if centre is True (which is the default) or shown at the default position if it is False.
The second overload also allows to specify the size of the dialog, which is then made at least this big, but never smaller than the size needed to show its contents. As the dialog can only show a single line of text, its height is normally determined by its contents and only the width of size is useful, so the height should usually be left as DefaultCoord.
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.
- Parameters:
message (string)
caption (string)
default_value (string)
parent (wx.Window)
x (int)
y (int)
centre (bool)
- Return type:
str
Note
Before wxWidgets 3.3.4, the position was ignored if centre was True, i.e. by default, and the second overload didn’t exist.
GetTextFromUser (message, caption, default_value, parent, pos, size=DefaultSize, centre=True)
- Parameters:
-
- Return type:
str
-
wx.GetTopLevelParent(window)¶
Returns the first top level parent of the given window, or in other words, the frame or dialog containing it, or nullptr.
Notice that if window is itself already a TLW, it is returned directly.
- Parameters:
window (wx.Window)
- Return type:
wx.Window
-
wx.GetTopLevelWindows()¶
Returns a list-like object of the the application’s top-level windows, (frames,dialogs, etc.)
- Return type:
WindowList
-
wx.GetTranslation(*args, **kw)¶
Overloaded Implementations:
GetTranslation (string, domain=’’, context=’’)
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. If you enable logging of trace messages with “i18n” mask (using wx.Log.AddTraceMask ) and debug logging is enabled (see Debugging ), a message is also logged in this case – which helps to find the strings which were not yet translated.
If 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 nearly the same thing as wx.GetTranslation , with the exception that the argument to wx._ must be a string literal.
If context is not empty (notice that this argument is only available starting from wxWidgets 3.1.1), item translation is looked up in the specified context. This allows having different translations for the same string appearing in different contexts, e.g. it may be necessary to translate the same English “Open” verb differently depending on the object it applies to. To do this, you need to use msgctxt in the source message catalog and specify different contexts for the different occurrences of the string and then use the same contexts in the calls to this function (or GETTEXT_IN_CONTEXT or GETTEXT_IN_CONTEXT_PLURAL macros).
This function is thread-safe.
- Parameters:
string (string)
domain (string)
context (string)
- Return type:
str
Note
If you want literal strings inside of this function to be translated, you need to use -kwxGetTranslation with xgettext . Also, don’t use T inside of this function with string literals, as xgettext won’t be able to extract them.
GetTranslation (string, plural, n, domain=’’, context=’’)
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.
See GNU gettext Manual for additional information on plural forms handling: http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms For a shorter alternative see the PLURAL macro.
This function is thread-safe.
- Parameters:
string (string)
plural (string)
n
domain (string)
context (string)
- Return type:
str
-
wx.GetUserHome(user='')¶
Returns the home directory for the given user.
If the user is empty (default value), this function behaves like wx.GetHomeDir (i.e. returns the current user home directory).
If the home directory couldn’t be determined, an empty string is returned.
- Parameters:
user (string)
- Return type:
str
-
wx.GetUserId()¶
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, this function looks in the environment variable USERNAME.
- Return type:
str
- Returns:
The login name if successful or an empty string otherwise.
-
wx.GetUserName()¶
This function returns the full user name (something like “John Smith”).
Under Windows, this function will attempt to get the user’s full name from the domain controller (or local computer); if that fails, it will return the login name (or empty string if that cannot be resolved).
- Return type:
str
- Returns:
The full user name if successful or an empty string otherwise.
-
wx.HandleFatalExceptions(doIt=True)¶
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++.
- Parameters:
doIt (bool)
- Return type:
bool
-
wx.HelpController(parentWindow=None)¶
Rather than being an alias for some class, the Python version of
HelpController is a factory function that creates and returns an
instance of the best Help Controller for the platform.
-
wx.HexToDec(*args, **kw)¶
Overloaded Implementations:
HexToDec (buf)
Convert 2-character hexadecimal string to decimal integer.
- Parameters:
buf (string) – String containing uppercase hexadecimal characters, not prefixed by 0x . Its length must be at least 2 characters. If it is longer than 2 characters, only first two will be converted to the number.
- Return type:
int
- Returns:
An integer number between 0 and 255 that is equivalent to the number in buf, or -1 if buf is not a hexadecimal string.
HexToDec (buf)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
buf (int)
- Return type:
int
-
wx.ImageFromBitmap(bitmap)¶
Create a Image from a wx.Bitmap
-
wx.ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None)¶
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.
-
wx.ImageFromData(width, height, data)¶
Compatibility wrapper for creating an image from RGB data
-
wx.ImageFromDataWithAlpha(width, height, data, alpha)¶
Compatibility wrapper for creating an image from RGB and Alpha data
-
wx.ImageFromStream(stream, type=BITMAP_TYPE_ANY, index=-1)¶
Load an image from a stream (file-like object)
-
wx.InfoMessageBox(parent)¶
Shows a message box with the information about the wxWidgets build used, including its version, most important build parameters and the version of the underlying GUI toolkit.
This is mainly used for diagnostic purposes and can be invoked by Ctrl-Alt-middle clicking on any wx.Window which doesn’t otherwise handle this event.
- Parameters:
parent (wx.Window)
- Return type:
None
-
wx.InitAllImageHandlers()¶
Initializes all available image handlers.
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.
- Return type:
None
-
wx.IntersectRect(r1, r2)¶
Calculate and return the intersection of r1 and r2. Returns None if there
is no intersection.
- Return type:
Any
-
wx.IsBusy()¶
Returns True if between two wx.BeginBusyCursor and wx.EndBusyCursor calls.
- Return type:
bool
-
wx.IsDragResultOk(res)¶
Returns True if res indicates that something was done during a DnD operation, i.e.
is neither error nor none nor cancel.
- Parameters:
res (DragResult)
- Return type:
bool
-
wx.IsMainThread()¶
Returns True if the current thread is what considers the GUI thread.
- Return type:
bool
-
wx.IsPlatform64Bit()¶
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.
- 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 bitness.
-
wx.IsPlatformLittleEndian()¶
Returns True if the current platform is little endian (instead of big endian).
The check is performed at run-time.
- Return type:
bool
See also
Byte Order Functions and Macros
-
wx.IsRunningUnderWine(ver=None)¶
Returns True only for MSW programs running under Wine.
Return True if the program is running under Wine and not a “native” MSW system.
- Parameters:
ver (wx.VersionInfo) – If non-null and the program is executing under Wine, it is filled with Wine version information (this output parameter is only available in wxWidgets 3.3.0 and later).
- Return type:
bool
- Returns:
True if running under Wine, False otherwise.
Added in version 4.1/wxWidgets-3.1.6.
-
wx.Kill(pid, sig=SIGTERM, rc=None, flags=KILL_NOCHILDREN)¶
Equivalent to the Unix kill function: send the given signal sig to the process with PID pid.
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 nullptr, it will be filled with a value from the KillError enum:
# KillError enumeration
wx.KILL_OK # no error
wx.KILL_BAD_SIGNAL # no such signal
wx.KILL_ACCESS_DENIED # permission denied
wx.KILL_NO_PROCESS # no such process
wx.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 .
- Parameters:
-
- Return type:
int
-
wx.LaunchDefaultApplication(document, flags=0)¶
Opens the document in the application associated with the files of this type.
The flags parameter is currently not used
Returns True if the application was successfully launched.
- Parameters:
document (string)
flags (int)
- Return type:
bool
-
wx.LaunchDefaultBrowser(url, flags=0)¶
Opens the url in user’s default browser.
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:
-
- 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).
-
wx.LoadFileSelector(what, extension, default_name='', parent=None)¶
Shows a file dialog asking the user for a file name for opening a file.
The file dialog will have FD_FILE_MUST_EXIST flag set.
- Parameters:
what (string)
extension (string)
default_name (string)
parent (wx.Window)
- Return type:
str
-
wx.LogDebug(message)¶
The function to use for debugging output.
In addition to not producing any output if the current log level is not high enough, just as all the other logging function, this function does nothing at all, and is not even present in the final executable code, if wxWidgets was compiled without debugging support, i.e. DEBUG_LEVEL is 0 (see for more details).
- Parameters:
message (String)
- Return type:
None
-
wx.LogError(message)¶
The functions to use for error messages, i.e.
the messages that must be shown to the user. The default processing is to pop up a message box to inform the user about it.
- Parameters:
message (String)
- Return type:
None
-
wx.LogFatalError(message)¶
Like wx.LogError , but also terminates the program with the exit code 3.
Using abort() standard function also terminates the program with this exit code.
- Parameters:
message (String)
- Return type:
None
-
wx.LogGeneric(level, message)¶
Logs a message with the given LogLevel.
E.g. using LOG_Message as first argument, this function behaves like wx.LogMessage .
- Parameters:
level (wx.LogLevel)
message (String)
- Return type:
None
-
wx.LogInfo(formatString, *args)¶
For low priority messages.
They are handled in the same way as messages logged by wx.LogMessage by the default logger but could be handled differently by the custom loggers.
- Parameters:
-
- Return type:
None
-
wx.LogMessage(message)¶
For all normal, informational messages.
They also appear in a message box by default (but it can be changed).
- Parameters:
message (String)
- Return type:
None
-
wx.LogStatus(*args, **kw)¶
Overloaded Implementations:
LogStatus (frame, message)
Messages logged by this function will appear in the statusbar of the frame or of the top level application window by default (i.e.
when using the second version of the functions).
If the target frame doesn’t have a statusbar, the message will be lost.
- Parameters:
-
- Return type:
None
LogStatus (message)
- Parameters:
message (String)
- Return type:
None
-
wx.LogSysError(message)¶
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.
- Parameters:
message (String)
- Return type:
None
-
wx.LogVerbose(message)¶
For verbose output.
Messages generated by these functions are suppressed by default, even if the log level is higher than wx.LOG_Info and need to be explicitly activated by calling wx.Log.SetVerbose .
Notice that this is done automatically by wxWidgets, unless the standard command line handling is overridden, if --verbose option is specified on the program command line, so using these functions provides a simple way of having some diagnostic messages not shown by default but which can be easily shown by the user if needed.
- Parameters:
message (String)
- Return type:
None
-
wx.LogWarning(message)¶
The function to use for warning messages.
Warnings are less severe than errors but still should normally be brought to the user’s attention. The default processing is to show them in a message box.
- Parameters:
message (String)
- Return type:
None
-
wx.MacThemeColour(themeBrushID)¶
- Return type:
wx.Colour
-
wx.MessageBox(message, caption=MessageBoxCaptionStr, style=OK | CENTRE, parent=None, x=DefaultCoord, y=DefaultCoord)¶
Show a general purpose message dialog.
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 ).
For example:
answer = wx.MessageBox("Quit program?", "Confirm",
wx.YES_NO | wx.CANCEL, main_frame)
if answer == wx.YES:
main_frame.Close()
message may contain newline characters, in which case the message will be split into separate lines, to cater for large messages.
- Parameters:
message (string) – Message to show in the dialog.
caption (string) – The dialog title.
style (int) – Combination of style flags described in wx.MessageDialog documentation.
parent (wx.Window) – Parent window.
x (int) – Horizontal dialog position (ignored under MSW). Use wx.DefaultCoord for x and y to let the system position the window.
y (int) – Vertical dialog position (ignored under MSW).
- Return type:
int
-
wx.MicroSleep(microseconds)¶
Sleeps for the specified number of microseconds.
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.
- Parameters:
microseconds (long)
- Return type:
None
-
wx.MilliSleep(milliseconds)¶
Sleeps for the specified number of milliseconds.
Notice that usage of this function is encouraged instead of calling usleep(3) directly because the standard usleep() function is not MT safe.
- Parameters:
milliseconds (long)
- Return type:
None
-
wx.MSWIsOnSecureScreen()¶
Check if the current desktop is the secure desktop.
Secure desktop is the desktop that is used for UAC prompts and sign-in screens and runs at system level i.e. as administrator. Using this function can be helpful to ensure that privileged operations are not allowed when running on this desktop.
- Return type:
bool
- Returns:
True if the current desktop is the secure desktop.
Added in version 4.3/wxWidgets-3.3.0.
Note
This function is only available under MSW.
-
wx.NewEventType()¶
Generates a new unique event type.
Usually this function is only used by DEFINE_EVENT and not called directly.
- Return type:
int
-
wx.NewId()¶
Generates an integer identifier unique to this run of the program.
- Return type:
int
Deprecated
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_ANY ID 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.
-
wx.NewIdRef(count=1)¶
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.
-
wx.Now()¶
Returns a string representing the current date and time.
- Return type:
str
-
wx.PostEvent(dest, event)¶
In a GUI application, this function posts event to the specified dest object using wx.EvtHandler.AddPendingEvent .
Otherwise, it dispatches event immediately using wx.EvtHandler.ProcessEvent . See the respective documentation for details (and caveats). Because of limitation of wx.EvtHandler.AddPendingEvent this function is not thread-safe for event objects having String fields, use wx.QueueEvent instead.
- Parameters:
-
- Return type:
None
-
wx.pydate2wxdate(date)¶
Convert a Python date or datetime to a DateTime object
-
wx.QueueEvent(dest, event)¶
Queue an event for processing on the given object.
This is a wrapper around wx.EvtHandler.QueueEvent , see its documentation for more details.
- Parameters:
dest (wx.EvtHandler) – The object to queue the event on, can’t be nullptr.
event (wx.Event) – The heap-allocated and non-null event to queue, the function takes ownership of it.
- Return type:
None
-
wx.RegisterId(id)¶
Ensures that Ids subsequently generated by wx.NewId do not clash with the given id.
- Parameters:
id (wx.WindowID)
- Return type:
None
-
wx.SafeShowMessage(title, text)¶
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:
-
- Return type:
bool
- Returns:
True If a message box was actually shown or False if the message was logged to the console because there is no safe to show it currently (the return value is only available since wxWidgets 3.1.5, the function doesn’t return anything in the previous versions).
-
wx.SafeYield(win=None, onlyIfNeeded=False)¶
Calls wx.App.SafeYield .
- Parameters:
-
- Return type:
bool
-
wx.SaveFileSelector(what, extension, default_name='', parent=None)¶
Shows a file dialog asking the user for a file name for saving a file.
The file dialog will not have FD_OVERWRITE_PROMPT flag set.
- Parameters:
what (string)
extension (string)
default_name (string)
parent (wx.Window)
- Return type:
str
-
wx.SecureZeroMemory(p, n)¶
Fills the memory block with zeros in a way that is guaranteed not to be optimized away by the compiler.
- Parameters:
p – Pointer to the memory block to be zeroed, must be non-null.
n (int) – The number of bytes to zero.
- Return type:
None
Added in version 4.1/wxWidgets-3.1.6.
Note
If security is vitally important in your use case, please have a look at the implementations and decide whether you trust them to behave as promised. Depending on the platform and available libraries, this may be implemented as RtlSecureZeroMemory (MS Windows), explicit_bzero() (FreeBSD), memset_s() (macOS), or a generic method which uses volatile to avoid the call from being optimized away.
-
wx.SetCursor(cursors)¶
Globally sets the cursor.
The globally set cursor overrides any cursor set for the individual windows, i.e. the specified cursor will be used for all windows of the application until this function is called again with an empty cursor bundle to restore the default behaviour of using the window-specific cursors.
Note that this function won’t update the cursor size if the DPI or user preferred cursor size changes, as this is considered unlikely to happen while this temporary cursor is shown. If you do want to update the cursor size, you need to handle wx.wxEVT_DPI_CHANGED and wx.wxEVT_SYS_METRIC_CHANGED events and call this function again from their handlers.
- Parameters:
cursors (wx.CursorBundle)
- Return type:
None
-
wx.Shell(command='')¶
Executes a command in an interactive shell window.
If no command is specified, then just the shell is spawned.
- Parameters:
command (string)
- Return type:
bool
See also
wx.Execute , External Program Execution Sample
-
wx.Shutdown(flags=SHUTDOWN_POWEROFF)¶
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) and that this function is only implemented under Unix and MSW.
-
wx.Sleep(secs)¶
Sleeps for the specified number of seconds.
- Parameters:
secs (int)
- Return type:
None
-
wx.StripMenuCodes(str, flags=Strip_All)¶
Strips any menu codes from str and returns the result.
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.
Notice that in most cases wx.MenuItem.GetLabelFromText or wx.Control.GetLabelText can be used instead.
- Parameters:
-
- Return type:
str
-
wx.SysErrorCode()¶
Returns the error code from the last system call.
This function uses errno on Unix platforms and GetLastError under Win32.
- Return type:
int
-
wx.SysErrorMsg(errCode=0)¶
Returns the error message corresponding to the given system error code.
If errCode is 0 (default), the last error code (as returned by wx.SysErrorCode ) is used.
Use wx.SysErrorMsgStr instead of this function especially in a multi-threaded application.
- Parameters:
errCode (long)
- Return type:
str
-
wx.SysErrorMsgStr(errCode=0)¶
Returns the error message corresponding to the given system error code.
If errCode is 0 (default), the last error code (as returned by wx.SysErrorCode ) is used.
Use this function instead of wx.SysErrorMsg , as the latter one is not thread-safe.
- Parameters:
errCode (long)
- Return type:
str
Added in version 4.1/wxWidgets-3.1.0.
-
wx.Trap()¶
Generate a debugger exception meaning that the control is passed to the debugger if one is attached to the process.
Otherwise the program just terminates abnormally.
If DEBUG_LEVEL is 0 (which is not the default) this function does nothing.
- Return type:
None
-
wx.version()¶
Returns a string containing version and port info
-
wx.WakeUpIdle()¶
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 .
- Return type:
None
-
wx.Yield()¶
Calls wx.AppConsole.Yield if there is an existing application object.
Does nothing if there is no application (which typically only happens early during the program startup or late during its shutdown).
- Return type:
bool
See also
EvtLoopBase.Yield()
-
wx.YieldIfNeeded()¶
Convenience function for wx.GetApp().Yield(True)
|