API¶
Functions
|
Show a blocking dialog window with a selection of buttons. |
|
Get file name interactively using a file dialog window. |
|
Get folder interactively using a file dialog window. |
|
Prompt the user with an input dialog. |
|
Show or close a non-blocking message window. |
Limited Interaction¶
Provides simple, backend-independant GUI tools for limited user interaction.
This module provides simple GUI tools that run in their own process, so that it cannot conflict with the current running event loop. If Matplotlib is imported, it updates its event loop in background while waiting for user action.
Additional parameters¶
All functions except get_folder and get_filename accept these parameters in addition to their own parameters:
- title
Title of the dialog window.
- icon
Can be either None, a str from [‘alert’, ‘clock’, ‘cloud’, ‘error’, ‘find’, ‘gear’, ‘info’,’light’, ‘lock’, ‘question’, ‘warning’] or a or a tuple of png files: (path_to_image_in_dialog.png, path_to_dock_icon.png)
- left
Distance between the monitor’s left edge and the window’s left edge in pixels. Parameters ‘left’ and ‘right’ cannot be used together.
- right
Distance between the monitor’s right edge and the window’s right edge in pixels. Parameters ‘left’ and ‘right’ cannot be used together.
- top
Distance between the monitor’s top edge and the window’s top edge in pixels. Parameters ‘top’ and ‘bottom’ cannot be used together.
- bottom
Distance between the monitor’s bottom edge and the window’s bottom edge in pixels. Parameters ‘top’ and ‘bottom’ cannot be used together.
- min_width
Minimal width of the dialog window in pixels.
- min_height
Minimal width of the dialog window in pixels.
Show a blocking dialog window with a selection of buttons.
- Parameters
message (
str) – Optional. Instruction to show to the user.choices (
Sequence[str]) – Optional. List of str, each entry corresponding to a button caption.kwargs – Consult the module’s help for additional parameters.
- Returns
The selected button index (0 = First button, 1 = Second button, etc.). If the user closes the window instead of clicking a button, a value of -1 is returned.
- Return type
int
-
limitedinteraction.get_filename(initial_folder='.', **kwargs)¶ Get file name interactively using a file dialog window.
- Parameters
initial_folder (
str) – Optional. The initial folder of the file dialog.- Returns
The full path of the selected file. An empty string is returned if the user cancelled.
- Return type
str
-
limitedinteraction.get_folder(initial_folder='.', **kwargs)¶ Get folder interactively using a file dialog window.
- Parameters
initial_folder (
str) – Optional. The initial folder of the file dialog.- Returns
The full path of the selected folder. An empty string is returned if the user cancelled.
- Return type
str
-
limitedinteraction.input_dialog(message='', labels=[], initial_values=[], masked=[], **kwargs)¶ Prompt the user with an input dialog.
- Parameters
message (
str) – Optional. Instruction to show to the user.labels (
Sequence[str]) – Optional. List of str: labels for each input.initial_values (
Sequence[str]) – Optional. List of str: initial values for each input.masked (
Sequence[bool]) – Optional. List of bool: True to mask an input using stars.kwargs – Consult the module’s help for additional parameters.
- Returns
If there was only one input, a str corresponding to this input is returned. If there was multiple inputs, a list of str is returned.
- Return type
str or List[str]
-
limitedinteraction.message(message, **kwargs)¶ Show or close a non-blocking message window.
- Parameters
message (
str) – The message to show. Use ‘’ to close the previous message windows.kwargs – Consult the module’s help for additional parameters.
- Returns
- Return type
None