{"id":19577185,"url":"https://github.com/asyncgui/asynctkinter","last_synced_at":"2026-03-11T10:32:06.055Z","repository":{"id":43354620,"uuid":"202930223","full_name":"asyncgui/asynctkinter","owner":"asyncgui","description":"Async/await-based framework for Tkinter","archived":false,"fork":false,"pushed_at":"2025-12-06T05:04:06.000Z","size":72,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-15T08:34:20.222Z","etag":null,"topics":["asynchronous","tkinter"],"latest_commit_sha":null,"homepage":"","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/asyncgui.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-08-17T20:50:59.000Z","updated_at":"2025-08-30T23:37:06.000Z","dependencies_parsed_at":"2022-08-27T10:23:33.196Z","dependency_job_id":"43d8245c-58d7-4e29-9477-301889181f3a","html_url":"https://github.com/asyncgui/asynctkinter","commit_stats":null,"previous_names":["gottadiveintopython/asynctkinter"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/asyncgui/asynctkinter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncgui%2Fasynctkinter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncgui%2Fasynctkinter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncgui%2Fasynctkinter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncgui%2Fasynctkinter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asyncgui","download_url":"https://codeload.github.com/asyncgui/asynctkinter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncgui%2Fasynctkinter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30378078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["asynchronous","tkinter"],"created_at":"2024-11-11T07:05:09.077Z","updated_at":"2026-03-11T10:32:06.038Z","avatar_url":"https://github.com/asyncgui.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AsyncTkinter\n\n[Youtube](https://youtu.be/8XP1KgRd3jI)\n\n`asynctkinter` is an async library that saves you from ugly callback-style code,\nlike most of async libraries do.\nLet's say you want to do:\n\n1. `print('A')`\n1. wait for 1sec\n1. `print('B')`\n1. wait for a label to be pressed\n1. `print('C')`\n\nin that order.\nYour code would look like this:\n\n```python\ndef what_you_want_to_do(label):\n    bind_id = None\n    print('A')\n\n    def one_sec_later(__):\n        nonlocal bind_id\n        print('B')\n        bind_id = label.bind('\u003cButton\u003e', on_press, '+')\n    label.after(1000, one_sec_later)\n\n    def on_press(event):\n        label.unbind('\u003cButton\u003e', bind_id)\n        print('C')\n\nwhat_you_want_to_do(...)\n```\n\nIt's not easy to understand.\nIf you use `asynctkinter`, the code above will become:\n\n```python\nimport asynctkinter as atk\n\nasync def what_you_want_to_do(clock, label):\n    print('A')\n    await clock.sleep(1)\n    print('B')\n    await atk.event(label, '\u003cButton\u003e')\n    print('C')\n\natk.start(what_you_want_to_do(...))\n```\n\n## Installation\n\nPin the minor version.\n\n```text\npoetry add asynctkinter@~0.4\npip install \"asynctkinter\u003e=0.4,\u003c0.5\"\n```\n\n## Usage\n\n```python\nimport tkinter as tk\nimport asynctkinter as atk\n\n\nasync def main(*, clock: atk.Clock, root: tk.Tk):\n    label = tk.Label(root, text='Hello', font=('', 80))\n    label.pack()\n\n    # waits for 2 seconds to elapse\n    await clock.sleep(2)\n\n    # waits for a label to be pressed\n    event = await atk.event(label, '\u003cButton\u003e')\n    print(f\"pos: {event.x}, {event.y}\")\n\n    # waits for either 5 seconds to elapse or a label to be pressed.\n    # i.e. waits at most 5 seconds for a label to be pressed\n    tasks = await atk.wait_any(\n        clock.sleep(5),\n        atk.event(label, '\u003cButton\u003e'),\n    )\n    if tasks[0].finished:\n        print(\"Timeout\")\n    else:\n        event = tasks[1].result\n        print(f\"The label got pressed. (pos: {event.x}, {event.y})\")\n\n    # same as the above\n    async with clock.move_on_after(5) as timeout_tracker:\n        event = await atk.event(label, '\u003cButton\u003e')\n        print(f\"The label got pressed. (pos: {event.x}, {event.y})\")\n    if timeout_tracker.finished:\n        print(\"Timeout\")\n\n    # waits for both 5 seconds to elapse and a label to be pressed.\n    tasks = await atk.wait_all(\n        clock.sleep(5),\n        atk.event(label, '\u003cButton\u003e'),\n    )\n\n    # nests as you want.\n    tasks = await ak.wait_all(\n        atk.event(label, '\u003cButton\u003e'),\n        atk.wait_any(\n            clock.sleep(5),\n            ...,\n        ),\n    )\n    child_tasks = tasks[1].result\n\n\nif __name__ == \"__main__\":\n    atk.run(main)\n```\n\n### threading\n\nUnlike `trio` and `asyncio`, `asynckivy` does not provide any I/O primitives.\nTherefore, if you don’t want to implement your own, using threads may be the best way to perform I/O without blocking the main thread.\n\n```python\nfrom concurrent.futures import ThreadPoolExecuter\nimport asynctkinter as atk\n\nexecuter = ThreadPoolExecuter()\n\nasync def async_fn(clock: atk.Clock):\n    # create a new thread, run a function inside it, then\n    # wait for the completion of that thread\n    r = await atk.run_in_thread(clock, thread_blocking_operation)\n    print(\"return value:\", r)\n\n    # run a function inside a ThreadPoolExecuter, and wait for its completion.\n    # (ProcessPoolExecuter is not supported)\n    r = await atk.run_in_executer(clock, executer, thread_blocking_operation)\n    print(\"return value:\", r)\n```\n\nUnhandled exceptions (excluding `BaseException` that is not `Exception`) are propagated to the caller\nso you can catch them like you do in synchronous code:\n\n```python\nimport requests\nimport asynctkinter as atk\n\nasync def async_fn(clock: atk.Clock):\n    try:\n        r = await atk.run_in_thread(clock, lambda: requests.get('htt...', timeout=10), ...)\n    except requests.Timeout:\n        print(\"TIMEOUT!\")\n    else:\n        print('RECEIVED:', r)\n```\n\n\n## Notes\n\n- You may want to read the [asyncgui's documentation](https://asyncgui.github.io/asyncgui/) as it is the foundation of this library.\n- You may want to read the [asyncgui_ext.clock's documentation](https://asyncgui.github.io/asyncgui-ext-clock/) as well.\n- I, the author of this library, am not even a tkinter user so there may be plenty of weird code in the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncgui%2Fasynctkinter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasyncgui%2Fasynctkinter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncgui%2Fasynctkinter/lists"}