Skip to main content

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')

message_calculating_macOS

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')

input_dialog_name_macOS

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')

input_dialog_credentials_macOS

choice_index = li.button_dialog('Please zoom on the figure and click Next.',
                                 choices=['Next', 'Cancel'],
                                 title='User interaction',
                                 icon='gear')

button_dialog_user_interaction_macOS

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

limitedinteraction-0.1a0.tar.gz (351.5 kB view hashes)

Uploaded Source

Built Distribution

limitedinteraction-0.1a0-py3-none-any.whl (357.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page