Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidhozic/tkclasswizard
Python library for GUI-interactive definition of objects / forms based on annotations (type hints). It allows the creation of forms based on class's definition. Works with Tkinter / TTKBootstrap.
https://github.com/davidhozic/tkclasswizard
annotations auto class define definition generic gui hint interactive object python python3 tkinter ttkbootstrap typing wizard
Last synced: 22 days ago
JSON representation
Python library for GUI-interactive definition of objects / forms based on annotations (type hints). It allows the creation of forms based on class's definition. Works with Tkinter / TTKBootstrap.
- Host: GitHub
- URL: https://github.com/davidhozic/tkclasswizard
- Owner: davidhozic
- License: mit
- Created: 2023-11-14T09:26:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-01T14:51:53.000Z (2 months ago)
- Last Synced: 2024-11-01T15:32:55.494Z (2 months ago)
- Topics: annotations, auto, class, define, definition, generic, gui, hint, interactive, object, python, python3, tkinter, ttkbootstrap, typing, wizard
- Language: Python
- Homepage: https://tkclasswizard.readthedocs.io/
- Size: 1.23 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=========================================================
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.---------------------
Links
---------------------
- `Releases `_
- Need help? Contact me in my `Discord server `_.
- **DOCUMENTATION**: https://tkclasswizard.readthedocs.io/---------------------
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) `_.. code-block:: bash
pip install tkclasswiz
----------------------
Example
----------------------.. image:: docs/source/guide/images/new_define_frame_struct_new_str.png
:width: 15cm.. code-block:: python
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 = diameterclass 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 framedef 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()