Skip to content

UnsignedArduino/TkZero

Repository files navigation

TkZero

PyPI Version Build Status Code Coverage PyLint Score License

A sane 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

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

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!

Basic Usage

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 = "Simple Entry Example"

# 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()