Quickly create simple GUIs in Python
Project description
Guichet
Quickly create simple GUIs in Python.
def happy_text(text: str, feeling_happy: bool):
if feeling_happy:
return text + "!!!"
else:
return text
gui = Guichet(happy_text)
gui.render()
The code above renders the following GUI:
You can also customize the layout by accessing the layout attribute of the Guichet object.
GUI controls are rendered according to type hints. Supported types include vanilla Python types (such as str, int and float), types from typing (such as Literal) and Pydantic types (such as SecretStr).
The full conversion table is as follows:
| Type hint | GUI control | Rendered as |
|---|---|---|
str |
Text input | |
int |
Text input | |
float |
Text input | |
bool |
Checkbox | |
pydantic.SecretStr |
Password input | |
typing.Literal with args (for example Literal["Option 1", "Option 2"]) |
Dropdown |
Guichet is based on the awesome PySimpleGUI library.
Installation
pip install guichet
Main API
Guichet(
main_function: Callable,
title: str = None,
output_size: tuple = (80, 20),
button_label: str = "Run",
theme: str = "Dark Blue 3",
show_default: bool = True,
ignore_params: list = None,
redirect_stdout: bool = True,
run_in_new_thread: bool = False,
wait_message: str = "Please wait...",
refresh_time: int = 1000,
window_param: str = None,
)
- main_function (Callable): The function in which the GUI is based on.
- title (str, optional): The window title. Defaults to
None, which means the name of themain_functionwill be used. - output_size (tuple, optional): The size of the output field, which indirectly sets the size of the window. Defaults to
(80, 20). - button_label (str, optional): The label of the button that calls
main_function. Defaults to"Run". - theme (str, optional): The window theme. You can explore the list of available themes following these instructions. Defaults to
"Dark Blue 3". - show_default (bool, optional): Whether to show the default values of the parameters in the GUI. Defaults to
True. - ignore_params (list, optional): Parameters to be ignored and not shown in the GUI. Defaults to
None. - redirect_stdout (bool, optional): Whether to redirect the standard output to the GUI's output field. If
True, regularprintcalls inmain_functionwill write to the output field. Defaults toTrue. - run_in_new_thread (bool, optional): Whether to run the
main_functionin a new thread. This should only beTrueif themain_functionis slow and you want to avoid blocking the GUI. Read the docs as some caveats apply when running a function in a separate thread. Defaults toFalse. - wait_message (str, optional): The message to be shown in the output field.
when a users presses the running button and the function has not yet
finished. Applicable only if
run_in_new_threadisTrue. Defaults to"Please wait...". - refresh_time (int, optional): Time (in milliseconds) for the window to check again for new events. Useful only in advanced scenarios where
run_in_new_threadisTrue. Use the highest value you can afford. Defaults to1000. - window_param (str, optional): The parameter of the
main_functionto where the GUI's main window object will be passed. Needed only in advanced scenarios where themain_functionneeds to communicate with the GUI. The parameter passed towindowwill not be shown in the GUI. Defaults toNone.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guichet-0.0.2.tar.gz.
File metadata
- Download URL: guichet-0.0.2.tar.gz
- Upload date:
- Size: 29.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a15133b4bfd3b91deb4b1198f2c234809b6138b9ce23d30becce6bd6a69ded1e
|
|
| MD5 |
42d2f1fa8e2c4bd3d3662ae7d44f0938
|
|
| BLAKE2b-256 |
aee59d5c03cbb0e8a7c5deddf596b5f427ef8f153f78dfb7580a80316d119979
|
File details
Details for the file guichet-0.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: guichet-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18aca440842218e68fd444c42629077668c83b059fe26f135de6794387cc1efc
|
|
| MD5 |
ea060a50aa2134b96631e127e7705216
|
|
| BLAKE2b-256 |
478872bb2e24bde1c16341f295377a6b98e054783ada9be17f524cf46b10a734
|