MCPcopy Index your code
hub / github.com/asyncgui/asynckivy

github.com/asyncgui/asynckivy @v0.11.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.11.0 ↗ · + Follow
400 symbols 1,218 edges 65 files 50 documented · 12% updated 26d agov0.11.0 · 2026-06-02★ 90
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

AsyncKivy

Youtube

asynckivyはKivy用のlibraryで、 よくあるasync libraryと同じでcallback関数だらけの醜いcodeを読みやすくしてくれます。 例えば

  1. Aを出力
  2. 一秒待機
  3. Bを出力
  4. buttonが押されるまで待機
  5. Cを出力

といった事を普通にやろうとするとcodeは

from kivy.clock import Clock

def what_you_want_to_do(button):
    print('A')

    def one_sec_later(__):
        print('B')
        button.bind(on_press=on_button_press)
    Clock.schedule_once(one_sec_later, 1)

    def on_button_press(button):
        button.unbind(on_press=on_button_press)
        print('C')

what_you_want_to_do(...)

のように読みにくい物となりますが、asynckivyを用いることで

import asynckivy as ak

async def what_you_want_to_do(button):
    print('A')
    await ak.sleep(1)
    print('B')
    await ak.event(button, 'on_press')
    print('C')

ak.managed_start(what_you_want_to_do(...))

と分かりやすく書けます。

Install方法

マイナーバージョンが変わった時は何らかの重要な互換性の無い変更が加えられた事を意味するので使う際はマイナーバージョンまでを固定してください。

pip install "asynckivy>=0.11,<0.12"

使い方

import asynckivy as ak

async def async_func(button):
    # 1秒待つ
    dt = await ak.sleep(1)
    print(f'{dt}秒経ちました')

    # buttonが押されるまで待つ
    await ak.event(button, 'on_press')

    # 'button.x'の値が変わるまで待つ
    __, x = await ak.event(button, 'x')
    print(f'button.x の現在の値は {x} です')

    # 'button.x'の値が100を超えるまで待つ
    if button.x <= 100:
        __, x = await ak.event(button, 'x', filter=lambda __, x: x>100)
        print(f'button.x の現在の値は {x} です')

    # buttonが押される か 5秒経つまで待つ (その1)
    tasks = await ak.wait_any(
        ak.event(button, 'on_press'),
        ak.sleep(5),
    )
    print("buttonが押されました" if tasks[0].finished else "5秒経ちました")

    # buttonが押される か 5秒経つまで待つ (その2)
    async with ak.move_on_after(5) as bg_task:
        await ak.event(button, 'on_press')
    print("5秒経ちました" if bg_task.finished else "buttonが押されました")

    # buttonが押され なおかつ 5秒経つまで待つ
    tasks = await ak.wait_all(
        ak.event(button, 'on_press'),
        ak.sleep(5),
    )

    # buttonが押され なおかつ [5秒経つ か 'other_async_func'が完了する] まで待つ
    tasks = await ak.wait_all(
        ak.event(button, 'on_press'),
        ak.wait_any(
            ak.sleep(5),
            other_async_func(),
        ),
    )
    child_tasks = tasks[1].result
    print("5秒経ちました" if child_tasks[0].finished else "other_async_funcが完了しました")

ak.managed_start(async_func(a_button))

より詳しい使い方はこちらをご覧ください。

Core symbols most depended-on inside this repo

Shape

Function 209
Method 135
Class 51
Route 5

Languages

Python100%

Modules by API surface

src/asynckivy/_etc.py22 symbols
src/asynckivy/_event.py20 symbols
investigation/speed_comparision_between_various_sleep_implementations.py19 symbols
src/asynckivy/modal.py14 symbols
tests/test_event_freq.py13 symbols
tests/test_event.py13 symbols
src/asynckivy/_sleep.py12 symbols
tests/test_visibility_aware_touch_events.py11 symbols
investigation/comparision_between_stateful_functions.py10 symbols
investigation/compare_various_ways_to_repeat_sleeping.py10 symbols
investigation/context_manager_args.py9 symbols
examples/painter4.py9 symbols

For agents

$ claude mcp add asynckivy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page