Provides simple, backend-independant GUI tools for simple user interaction.
Project description
Limited Interaction
Provides simple, backend-independant GUI tools for limited user interaction.
This module provides simple GUI tools that run in their own separate process, which proves to be useful in interactive IPython sessions. It has no external dependency and updates the matplotlib event loop in background (if matplotlib is installed) while waiting for user action.
Why another GUI module
This module may interest people transitionning from Matlab to python, who miss Matlab's no-brainer ui functions such as msgbox, menu, etc. I could not find equivalent functions in the vast python ecosystem that are:
- blocking when needed;
- but still continue to refresh matplotlib when launched in an interactive
IPython session;
- independent of the currently running IPython event loop.
This module is designed to be a limited but extra-easy option to interact with a user without even thinking about what is a GUI. It has no dependencies and should work out of the box in any situation where the python interpreter is run locally*. It is based on tkinter, but since it starts its own processes, it can be run conjointly with any other backend (Qt, wxwindows, etc.).
Please note that this module won't work in remote jupyter sessions or in REPL environments, since in these cases, python is not running locally.
Usage
Importing
import limitedinteraction as li
Creating a persistent message window
li.message('Please wait a few moments.',
title='Calculating...',
icon='clock')
This is a non-blocking function. Any code after this call is executed immediately, while this message window stays in foreground.
# Close the message window
li.message('')
Asking for user input
name = li.input_dialog('What is your name?', icon='question')
This is a blocking function. We wait for user input before continuing. Meanwhile, Matplotlib's event loop is refreshed so that the user can interact with figures.
This same function can have several inputs and some inputs can be masked:
credentials = li.input_dialog('Please enter your credentials',
descriptions=['Username:', 'Password:'],
initial_values=['username', 'password'],
masked=[False, True],
icon='lock')
choice_index = li.button_dialog('Please zoom on the figure and click Next.',
choices=['Next', 'Cancel'],
title='User interaction',
icon='gear')
This is a blocking function. We wait for a choice before continuing. Meanwhile, Matplotlib's event loop is refreshed so that the user can interact with figures.
Other functions
Get a file name using the operating system's standard file selection window:
filename = li.get_filename()
Get a folder name using the operating system's standard folder selection window:
folder = li.get_folder()
Known issues
If you are using macOS Mojave or Anaconda python on Linux, you may have these problems:
-
On macOS Mojave, tkinter is known to be seriously broken. If you use a Mac, please use any other OS version than Mojave.
-
On Anaconda python on Linux, tkinter fonts are very ugly. It still works, but it looks ancient.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for limitedinteraction-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fd33bf6897fcaf98f2702049a871f09e5cfabba96967505fc3f5750c0eb3df2 |
|
MD5 | 169b04e820c52cb10bfcfd4393726f84 |
|
BLAKE2b-256 | 195306698c213e162ac835a36459be47d87749909f1404923faba0b021958eb3 |