Skip to main content

TkZero - a lightweight and Pythonic wrapper around Tkinter.

Project description

TkZero

PyPI Version Build Status Code Coverage License Code style: black

A lightweight and Pythonic wrapper around Tkinter.

Documentation is available on GitHub pages. You can find the raw HTML for the docs in the docs/ directory. pdoc is used to generate the documentation.

You can find examples in the Examples/ directory and tests in the Tests/ directory.

Installation

Using PyPI (recommended)

Windows:

pip install TkZero

macOS and Linux:

pip3 install TkZero

You may need to use the user (-U) flag to install if you are not using a virtual environment!

From source

Using Git

Make sure you have Git before following these steps. If you are on Windows, I highly suggest you install the Windows Terminal as it's much better than the command prompt.

  1. cd into your project root.
  2. Run git clone https://github.com/UnsignedArduino/TkZero
  3. Run cd TkZero
  4. Install TkZero's dependencies with pip install -r requirements.txt. (pip3 on Linux and macOS - you may also need to use the user (-U) flag if you are not using a virtual environment)

That's it!

Downloading via zip

Go to the main page of this repo, click on the green Code button and click Download ZIP. Once the zip file finishes downloading, extract all of it to your project root. Then open a terminal and run:

  1. cd into your project root.
  2. cd TkZero
  3. Install TkZero's dependencies with pip install -r requirements.txt. (pip3 on Linux and macOS - you may also need to use the user (-U) flag if you are not using a virtual environment)

That's it!

A simple example

import tkinter as tk

from TkZero.Button import Button
from TkZero.Entry import Entry
from TkZero.Label import Label
from TkZero.MainWindow import MainWindow

# Make the main window and give it a title
root = MainWindow()
root.title = "Log in"

# Create a label and grid it
Label(root, text="Username: ").grid(row=0, column=0, sticky=tk.NW)

# Create an entry and grid it
username = Entry(root, width=30)
username.grid(row=0, column=1, sticky=tk.NW)

# Create more labels and entries
Label(root, text="Password: ").grid(row=1, column=0, sticky=tk.NW)

password = Entry(root, width=30, show="*")
password.grid(row=1, column=1, sticky=tk.NW)


# "Submit" the form
def submit():
    root.enabled = False
    print(username.value)
    print(password.value)


# Create a button to "submit"
submit = Button(root, text="Submit", command=submit)
submit.grid(row=3, column=0, columnspan=2, sticky=tk.NSEW)

# Start the mainloop like in Tkinter
root.mainloop()

See? Looks much better than Tkinter code ;)

Help! I don't understand how to use this!

If you still don't understand, please open a discussion - I'd love to help you!

How you can help

Want to help! Great! Here are some ways you can help: (from easiest to hardest)

Suggest an idea

Are you annoyed by something in Tkinter that hasn't been wrapped in TkZero? Please comment in this discussion! You can also open an issue for a feature request here but don't forget to make sure that there isn't an issue for it open already!

Report a bug

Found a bug? Great! Please report it here but don't forget to make sure that there isn't an issue for it open already!

Run unit tests and improve test coverage

As I develop on Windows, I'm unable to run my unit tests on macOS and Linux. If you could run your unit tests and report any failures as a bug report, I would be ever grateful. Even better, you can improve the test coverage by adding on to the unit tests!

To get the coverage make sure you install coverage with pip install coverage (pip3 for macOS and Linux and you may need to use the user (-U) flag if you are not in a virtual environment) and then you can run these commands: (make sure you git cloned this repo and cd into it!)

coverage erase
coverage run --include=TkZero/* -m pytest -ra
coverage report -m

Adding examples

You can help by adding or improving (or simplifying!) examples, like for individual widgets here or "full applications" here.

Help fix bugs and full-fill feature requests with a pull request

Squashing bugs and implementing features can take time. If you are impatient like me, you can help to try to fix those bugs and full-fill feature requests! Please do not forget to run your code through black, flake8, pylint, and mypy! You can also automate this by using tox at the repo root:

tox -e py39

Donate

If you want to give me your money (even just 1 dollar goes a long way) here are my addresses :)

Don't worry, I'll let you mine to it as well ;)

Monero address:

89tu7CLRFHV1b1qZ6Y8WixeSsFpUJm1gC3dAx5jUb7gqHP5ssczPqyRP7Pt98uEB3TQ4hEEoB7wTA97AC8gXU89o6gNYeyD

Bitcoin address:

bc1qgq88e0hcf2q2xhg503zmhaqz7d7dfc8k9nvu9x

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

TkZero-0.2.0.tar.gz (168.7 kB view details)

Uploaded Source

Built Distribution

TkZero-0.2.0-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

Details for the file TkZero-0.2.0.tar.gz.

File metadata

  • Download URL: TkZero-0.2.0.tar.gz
  • Upload date:
  • Size: 168.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for TkZero-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5687d8522cc0ae2a324e96a940487de281e9b9fdbb320ccc8589c03723ce5654
MD5 a390b3bd06cda76c4f80d6683e035285
BLAKE2b-256 074c9e973623dac6cd6b093c8079f4701053bcb187a453b744a1eb94d9f64f19

See more details on using hashes here.

File details

Details for the file TkZero-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: TkZero-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for TkZero-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 441e3a1ff904a835a8a9ec4fe357f8e019a51c157b1399966a2c94e787a4603d
MD5 2c773cdc78054e8cc4a7d2a720d65ae3
BLAKE2b-256 bcfb46ad15d15fb83b281a1d3c2684f7069d2ed14553b59e1965db75970b92c0

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