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

add an asyncio option to the code generator #91

Open
matecsaj opened this issue Mar 15, 2022 · 1 comment
Open

add an asyncio option to the code generator #91

matecsaj opened this issue Mar 15, 2022 · 1 comment

Comments

@matecsaj
Copy link

matecsaj commented Mar 15, 2022

The use of asynchio is becoming increasingly common. To those using it, it would be helpful if your generator had an option to enable it. The generator could import the library and add decorations and so forth. The default for the option should be to not use asyncio.

@rdbende
Copy link
Contributor

rdbende commented Mar 20, 2022

Asynchronous programming is a nice thing, but implementing it with GUI frameworks isn't that easy, since both the GUI framework and asyncio uses it's own event loop, that will block each other. This could be solved by using threading, but the thing is, Tkinter isn't thread-safe.
So you have to keep Tkinter in the main thread, and start asyncio in another thread. From the asyncio thread you have to make thread-safe callbacks via call_soon_threadsafe to Tkinter, so it won't raise errors like main loop is not in the main thread or calling tcl from s different department.
For more information I really recommend the asyncio section on this page: http://tkdocs.com/tutorial/eventloop.html (actually the whole page is really useful, if you want to understand Tkinter and Tk).

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

No branches or pull requests

2 participants