Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkvariable-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkvariable-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

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

Hashes for tkvariable-0.1.0.tar.gz
Algorithm Hash digest
SHA256 19fdf2a4ec9f3a673d2efc42ede3289c229969986430c2ddefe8ed099c39c9fd
MD5 e5a4168e69c688b22e3659089ba95585
BLAKE2b-256 3b4db5e276a869e9e5e1f86049a674f5d43bd1c1c5c74b9421da72cd848a206a

See more details on using hashes here.

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

Hashes for tkvariable-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b781dca9305d528f7d070cc1579e6d28bdf34b939719a70caaa74a36da3632
MD5 e8c2ce45970bae7224ba52ddc818505a
BLAKE2b-256 f5798ed3d81e0a0a8d9dce3c6b3afa4e7227cb65947a93e3aec170ee07cf53ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page