Skip to main content

TkClassWizard

TkClassWizard - define objects graphically based on class annotations. The library allows users to create abstract “ObjectInfo” objects based on the class’s parameters, which can later be converted to real Python objects and vice versa.

Main features

  • Interactive definition of Python objects based on annotations.

  • Tkinter based

  • JSON templates

  • Polymorphism

  • Generic classes

  • Type aliases

  • Data validation

  • Conversion of defined data to Python objects and vice-versa.

Installation

TkClassWizard can be installed though command prompt/terminal using the bottom commands.

Pre-requirement: Python (minimum v3.9)

pip install tkclasswiz

Example

docs/source/guide/images/new_define_frame_struct_new_str.png
import tkinter as tk
import tkinter.ttk as ttk
import tkclasswiz as wiz


# Normal Python classes with annotations (type hints)
class Wheel:
    def __init__(self, diameter: float):
        self.diameter = diameter

class Car:
    def __init__(self, name: str, speed: float, wheels: list[Wheel]):
        self.name = name
        self.speed = speed
        self.wheels = wheels

# Tkinter main window
root = tk.Tk("Test")

# Modified tkinter Combobox that will store actual objects instead of strings
combo = wiz.ComboBoxObjects(root)
combo.pack(fill=tk.X, padx=5)

def make_car(old = None):
    """
    Function for opening a window either in new definition mode (old = None) or
    edit mode (old != None)
    """
    assert old is None or isinstance(old, wiz.ObjectInfo)

    window = wiz.ObjectEditWindow()  # The object definition window / wizard
    window.open_object_edit_frame(Car, combo, old_data=old)  # Open the actual frame

def print_defined():
    data = combo.get()
    data = wiz.convert_to_objects(data)  # Convert any abstract ObjectInfo objects into actual Python objects
    print(f"Object: {data}; Type: {type(data)}",)  # Print the object and it's datatype


# Main GUI structure
ttk.Button(text="Define Car", command=make_car).pack()
ttk.Button(text="Edit Car", command=lambda: make_car(combo.get())).pack()
ttk.Button(text="Print defined", command=print_defined).pack()
root.mainloop()

Metadata

Release files for TkClassWiz 1.4.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TkClassWiz 1.4.10
File Size Uploaded
TkClassWiz-1.4.10.tar.gz 29.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for TkClassWiz 1.4.10
File Interpreter ABI Platform
TkClassWiz-1.4.10-py3-none-any.whl Python 3 none any Details

Total release size: 67.2 kB

Release files / TkClassWiz-1.4.10.tar.gz

Download URL TkClassWiz-1.4.10.tar.gz
Size 29.0 kB
Tags Source
SHA-256 checksum
How to use checksums
408463ec339ad119abc4bf39af02ff8311e7ce608313da7b344bfea487ee6596
BLAKE2b-256 checksum
How to use checksums
4f01d676451e0e272c79c54a6182e89a1208e7ca1171a95939be2026738a42dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / TkClassWiz-1.4.10-py3-none-any.whl

Download URL TkClassWiz-1.4.10-py3-none-any.whl
Size 38.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b89197ab7d0f97dbb528ec3f8aa434be918dd14731fec5a3d040a80f46d99e6c
BLAKE2b-256 checksum
How to use checksums
488eb14983854c648c0579519039e2fc11f658bb660750cbd9cc43a7c2d24b75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.4.10 This release

2 release files

1.4.9

2 release files

1.4.8

2 release files

1.4.7

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page