Efficient Tkinter variable management with dynamic creation and tracing.
Project description
TkVar: Tkinter Variable Manager
TkVar is a Python utility that simplifies managing variables in Tkinter applications. With a singleton implementation, it ensures efficient handling of variables, supports dynamic creation and updates, and integrates seamlessly with Tkinter's tracing mechanisms for variable change events.
Features
- Singleton Design: Guarantees a single instance of the variable manager.
- Dynamic Variable Management: Automatically assigns appropriate Tkinter variable types (
StringVar,IntVar,DoubleVar,BooleanVar) based on value types. - Trace Support: Easily attach and remove callbacks to monitor or respond to variable changes.
- Centralized Access: Manage all variables through a single interface.
Installation
You can integrate TkVar into your Tkinter projects by including the tkvariable.py file.
Usage
Initialization
Start by initializing the TkVar instance with a tk.Tk master:
import tkinter as tk
from tkvariable import variable
root = tk.Tk()
variable.init(root)
Creating and Accessing Variables
variable["username"] = "Guest" # Create a StringVar
print(variable["username"].get()) # Access the variable
Tracing Variable Changes
def on_change(*args):
print("Variable changed!")
variable.map("username", on_change, "write")
Updating Variable Values
variable.set("username", "Admin")
Retrieving All Variables
print(variable.variables)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tkvariable-0.1.0.tar.gz.
File metadata
- Download URL: tkvariable-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19fdf2a4ec9f3a673d2efc42ede3289c229969986430c2ddefe8ed099c39c9fd
|
|
| MD5 |
e5a4168e69c688b22e3659089ba95585
|
|
| BLAKE2b-256 |
3b4db5e276a869e9e5e1f86049a674f5d43bd1c1c5c74b9421da72cd848a206a
|
File details
Details for the file tkvariable-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tkvariable-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5b781dca9305d528f7d070cc1579e6d28bdf34b939719a70caaa74a36da3632
|
|
| MD5 |
e8c2ce45970bae7224ba52ddc818505a
|
|
| BLAKE2b-256 |
f5798ed3d81e0a0a8d9dce3c6b3afa4e7227cb65947a93e3aec170ee07cf53ce
|