{"id":21127019,"url":"https://github.com/pyrustic/viewable","last_synced_at":"2026-05-19T17:33:13.083Z","repository":{"id":60723504,"uuid":"379410696","full_name":"pyrustic/viewable","owner":"pyrustic","description":"Class to implement a GUI view with lifecycle","archived":false,"fork":false,"pushed_at":"2023-02-25T01:59:50.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T18:21:06.574Z","etag":null,"topics":["app","desktop","event","frontend","gui","library","lifecycle","lightweight","pyrustic","python","tkinter"],"latest_commit_sha":null,"homepage":"https://pyrustic.github.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyrustic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-22T21:59:22.000Z","updated_at":"2021-11-16T20:25:05.000Z","dependencies_parsed_at":"2024-11-20T06:15:11.300Z","dependency_job_id":null,"html_url":"https://github.com/pyrustic/viewable","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"dfd91ec2ade39c8f15505a0820ec3d5f65d8bcd6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Fviewable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Fviewable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Fviewable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyrustic%2Fviewable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyrustic","download_url":"https://codeload.github.com/pyrustic/viewable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243573166,"owners_count":20312879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["app","desktop","event","frontend","gui","library","lifecycle","lightweight","pyrustic","python","tkinter"],"created_at":"2024-11-20T04:46:16.261Z","updated_at":"2025-12-29T17:14:01.620Z","avatar_url":"https://github.com/pyrustic.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- Image --\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/cyberpunk-cover.png\" alt=\"Figure\" width=\"970\"\u003e\n    \u003cp align=\"center\"\u003e\n    \u003ci\u003e  \u003c/i\u003e\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\n\u003c!-- Intro Text --\u003e\n# Viewable\n\u003cb\u003e Implement better Views for your Tkinter Python app \u003c/b\u003e\n\nThis project is part of the [Pyrustic Open Ecosystem](https://pyrustic.github.io).\n\n\u003c!-- Quick Links --\u003e\n[Installation](#installation) | [Reference](https://github.com/pyrustic/viewable/tree/master/docs/modules#readme)\n\n## Overview\n\nViews are the building blocks of your desktop application GUI. `Viewable` allows you to implement Views that are maintainable and easily extensible. Viewable defines a View in terms of its lifecycle. And so, you can split your source code to align with the main states a View goes through: `init`, `build`, `map`, and `destroy`.\n\nHere's how to implement a View with `Viewable`:\n\n```python\nimport tkinter as tk\nfrom viewable import Viewable\n\n\nclass View(Viewable):\n    def __init__(self, master):\n        super().__init__()\n        self._master = master\n\n    def _build(self):\n        \"\"\"\n        This is the only mandatory method to implement.\n        You define the body of the view here\n        \"\"\"\n        # the body is generally either\n        # a tk.Frame instance\n        # or a tk.Toplevel instance\n        self._body = tk.Frame(self._master)\n        label = tk.Label(self._body, text=\"Hello Friend !\")\n        label.pack()\n\n    def _on_map(self):\n        \"\"\" This method is called when the view is mapped for the first time \"\"\"\n\n    def _on_destroy(self):\n        \"\"\" This method is called when the view is destroyed \"\"\"\n\n\n# root\nroot = tk.Tk()\n\n# the view\nview = View(root)\n\n# the method build_pack() builds then packs the view\n# In fact you could do:\n#   view.build() then view.pack()\n# or:\n#   view.build() then view.body.pack()\nview.build_pack()  # it accepts arguments like the Tkinter pack() method\n\n# others ways to install a view:\n# .build_grid(), .build_place(), .build_wait()\n\n# you can access the body of the view via\n# its .body property\nview.body  # here, the body is a tk.Frame\n\n# To destroy a view, call the method .destroy()\nview.destroy()\n\n# The .state property reveals the state of the view:\n# 'new', 'built', 'mapped', 'destroyed'.\nprint(view.state)\n\n# mainloop\nroot.mainloop()\n\n```\n\n\n\n\n\n\n## Installation\n```bash\npip install viewable\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyrustic%2Fviewable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyrustic%2Fviewable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyrustic%2Fviewable/lists"}