Skip to main content

Generate a Tkinter GUI from any Python program

Project description

Python Auto GUI

Generate a Tkinter GUI from any Python program

  • Creates a Tkinter GUI to replace any command line interface
  • Interprets your existing code, removing the need for programming a GUI by hand.
  • Dynamically generates tidy applications, with quality of life features such as exporting data to CSV or PDF.
adventure quiz greetings
A choose-your-own adventure A simple maths quiz A hello world example

Quick-start

from autogui import print, input, run   # import overrides, and run function
run()   # start GUI

10 second example

from autogui import print, input, run   # import overrides, and run function
run()   # start GUI

myAnswer = input("What is your name?")    # renders a textbox and waits for user input

input("Click me to continue")   # renders a button and waits for user input

print("Hello, "+myAnswer)   # renders text
Function Feature
input() Creates a button and waits for the user to press it
var = input() Creates a text box and waits for the user to enter an input
print() Creates a label with the passed text

Footer + export options

from autogui import input, run, footer   # import overrides, and run + footer functions
run()   # start GUI

myAnswer = input("What is your name?")    # renders a textbox and waits for user input

footer()   # renders a footer with export options
  • The footer function is an optional function that can be called at the end of your program to render a footer with export options.
  • These export options are:
Export Function
CSV Export Q/A's as a CSV file.
PDF Export as a PDF document (currently TODO).
JPG Export as a JPG image (currently TODO).
  • PDF and JPG export are not yet implemented, as usual methods of exporting the tkinter canvas using postscript don't support export of widgets.

Explaining the code

In order to work as a drop-in solution for existing code, we override existing functions in the Python language.

Print: The print function is overridden to create a label with the passed text.

Input: The input function analyzes the function call to determine if the user is requesting a text box or a button. If the function saves the returned value to a variable, it will create a text box. If the function output is not saved to a variable, it will create a button.

Thread communication: The Tkinter GUI runs in a seperate thread to the main application, in order to prevent UI blocking. Communication between the main application and the GUI is done using queues. Print and Input functions place messages in the queue, and the GUI reads them and renders the appropriate UI. The GUI can also place messages on a seperate queue, for instance to return user input from text boxes or buttons to the main application.

Themeing

Tkinter supports themes to improve the default look and feel of the GUI. rdbende/Azure-ttk-theme is the theme used in screenshots for this package (with "light" (default) and "dark" themes). If no theme folder is found in themes/azure.tcl relative to the main .py file, the default tkinter theme is used.

Setting a new theme

from autogui import print, input, run   # import overrides, and run function
run(theme_name="light", theme_source="folder/new_theme.tcl")   # start GUI

License

MIT

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

pythonautogui-0.0.2.tar.gz (80.2 kB view details)

Uploaded Source

Built Distribution

pythonautogui-0.0.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pythonautogui-0.0.2.tar.gz.

File metadata

  • Download URL: pythonautogui-0.0.2.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pythonautogui-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3de0c538e4386f9edf39584da4dc144eb8ac6a00c3c0dceb079ec5ba5c0cf45f
MD5 46f146d69a08da6612c7c67e7843106d
BLAKE2b-256 62430fda59da3795928a5c928d18e260b761890ef5e5f9ef0b7e93fd0a0a6c83

See more details on using hashes here.

File details

Details for the file pythonautogui-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pythonautogui-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e20f71d08270c5781893735b6742a803458da6ef6032d2de027bab217fadd05
MD5 81c435d97962b7c5945561b3660c3318
BLAKE2b-256 90327ad6e7b0e5e7941be06c05e06a605276c8f6db7f5cf90d2799e5776e3fd3

See more details on using hashes here.

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