tkcomponents


Nametkcomponents JSON
Version 4.0.2 PyPI version JSON
download
home_pagehttps://github.com/immijimmi/tkcomponents
SummaryAn OOP framework for Tkinter, inspired by React
upload_time2023-07-06 03:46:20
maintainer
docs_urlNone
authorimmijimmi
requires_python
licenseMIT
keywords ui gui graphical user interface
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

```python
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
```python
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()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/immijimmi/tkcomponents",
    "name": "tkcomponents",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ui,gui,graphical,user,interface",
    "author": "immijimmi",
    "author_email": "immijimmi1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d4/f8/89821a8b35bf0d75016f9c907dc59713d6fa84302f4b72549fe01f54f444/tkcomponents-4.0.2.tar.gz",
    "platform": null,
    "description": "# tkcomponents\r\n\r\n###### An OOP framework for Tkinter, inspired by React\r\n\r\n## Quickstart\r\n\r\n### Setup\r\n\r\nBelow is an example of a custom component, a number label which updates its value periodically.\r\n\r\n```python\r\nfrom tkinter import Label, IntVar\r\n\r\nfrom tkcomponents import Component\r\n\r\n\r\nclass Counter(Component):\r\n    def __init__(self, container):\r\n        super().__init__(container, update_interval_ms=250)  # The component will update 4 times per second\r\n\r\n        self._count__var = IntVar()\r\n        self._count__var.set(0)\r\n\r\n    @property\r\n    def _needs_render(self):\r\n        return self._count__var.get() % 5 == 0  # A full re-render will trigger on multiples of 5\r\n\r\n    def _update(self):\r\n        current_count = self._count__var.get()\r\n\r\n        self._count__var.set(current_count+1)  # The counter will increase by 1 each update, a total of +4 per second\r\n\r\n    def _render(self):\r\n        Label(self._frame, textvariable=self._count__var).pack()\r\n```\r\n\r\n### App Boilerplate\r\n```python\r\nfrom tkinter import Tk\r\n\r\n\r\nclass App:\r\n    def __init__(self):\r\n        self.window = Tk()\r\n\r\n        Counter(self.window).render().pack()  # Note that .render() is called from outside the component, not ._render()\r\n\r\n        self.window.mainloop()\r\n\r\nif __name__ == \"__main__\":\r\n    App()\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An OOP framework for Tkinter, inspired by React",
    "version": "4.0.2",
    "project_urls": {
        "Download": "https://github.com/immijimmi/tkcomponents/archive/refs/tags/v4.0.2.tar.gz",
        "Homepage": "https://github.com/immijimmi/tkcomponents"
    },
    "split_keywords": [
        "ui",
        "gui",
        "graphical",
        "user",
        "interface"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d4f889821a8b35bf0d75016f9c907dc59713d6fa84302f4b72549fe01f54f444",
                "md5": "e2fe1ec46f4fdc47bf3ce8ebac217398",
                "sha256": "f1f87d7c5067c4b84b8e3da0d54de20d3c824a84ab4d09be90a2670952d8c8c3"
            },
            "downloads": -1,
            "filename": "tkcomponents-4.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e2fe1ec46f4fdc47bf3ce8ebac217398",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14129,
            "upload_time": "2023-07-06T03:46:20",
            "upload_time_iso_8601": "2023-07-06T03:46:20.814954Z",
            "url": "https://files.pythonhosted.org/packages/d4/f8/89821a8b35bf0d75016f9c907dc59713d6fa84302f4b72549fe01f54f444/tkcomponents-4.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-06 03:46:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "immijimmi",
    "github_project": "tkcomponents",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tkcomponents"
}
        
Elapsed time: 0.08612s