Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototyping the coroutine support #313

Merged

Conversation

ceccopierangiolieugenio
Copy link
Owner

@ceccopierangiolieugenio ceccopierangiolieugenio commented Jan 22, 2025

Thanks to @SZRabinowitz for this code snippet that helped me prototype the coroutine support in the signal framework

import asyncio
import time

import TermTk as ttk

root = ttk.TTk(layout=ttk.TTkVBoxLayout())
res = ttk.TTkLabel(parent=root)
num = ttk.TTkLabel(parent=root, text=1)
button_add = ttk.TTkButton(parent=root, text="+")
button_add.clicked.connect(lambda: num.setText(int(num.text()) + 1))
button_call = ttk.TTkButton(parent=root, text="Call")
ttk.TTkButton(parent=root, text="Quit").clicked.connect(ttk.TTkHelper.quit)


async def call():
    await asyncio.sleep(5)
    res.setText("Calling...")


def call_call():
    asyncio.create_task(call())


button_call.clicked.connect(call_call)

root.mainloop()

@ceccopierangiolieugenio ceccopierangiolieugenio linked an issue Jan 22, 2025 that may be closed by this pull request
@ceccopierangiolieugenio ceccopierangiolieugenio added the enhancement New feature or request label Jan 23, 2025
@ceccopierangiolieugenio ceccopierangiolieugenio merged commit 3cb7bc4 into main Jan 23, 2025
4 checks passed
@ceccopierangiolieugenio ceccopierangiolieugenio deleted the 310-extend-the-support-to-coroutines-as-slots branch January 23, 2025 12:28
@ceccopierangiolieugenio
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend the support to coroutines as slots
2 participants