Skip to main content

tkcomponents

An OOP framework for Tkinter, inspired by React

Quickstart

Setup

Below is an example of a custom component, a number label which updates its value periodically.

from tkinter import Label, IntVar

from tkcomponents import Component


class Counter(Component):
    def __init__(self, container):
        super().__init__(container, update_interval_ms=250)  # The component will update 4 times per second

        self._count__var = IntVar()
        self._count__var.set(0)

    @property
    def _needs_render(self):
        return self._count__var.get() % 5 == 0  # A full re-render will trigger on multiples of 5

    def _update(self):
        current_count = self._count__var.get()

        self._count__var.set(current_count+1)  # The counter will increase by 1 each update, a total of +4 per second

    def _render(self):
        Label(self._frame, textvariable=self._count__var).pack()

App Boilerplate

from tkinter import Tk


class App:
    def __init__(self):
        self.window = Tk()

        Counter(self.window).render().pack()  # Note that .render() is called from outside the component, not ._render()

        self.window.mainloop()

if __name__ == "__main__":
    App()

Metadata

Release files for tkcomponents 4.0.2

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

Source distribution (sdist)

Source distribution for tkcomponents 4.0.2
File Size Uploaded Provenance Actions
tkcomponents-4.0.2.tar.gz 14.1 kB Without provenance Details for tkcomponents-4.0.2.tar.gz

Release files / tkcomponents-4.0.2.tar.gz

Download URL tkcomponents-4.0.2.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f1f87d7c5067c4b84b8e3da0d54de20d3c824a84ab4d09be90a2670952d8c8c3
BLAKE2b-256 checksum
How to use checksums
d4f889821a8b35bf0d75016f9c907dc59713d6fa84302f4b72549fe01f54f444
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for tkcomponents 4.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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