Asyncio-tkinter hope this is the right thread for this
Hi I am trying to build an application on the raspberry Pi using python3.6 and tkinter for the GUI. It is an entry system for a community project and so I need to be able to receive FOB swipe data into the application which is running a tkinter user interface. Any who I have all the components working ok but can't seem to get them to work together. I am trying to use asyncio but keep clashing with the tkinter event loop, so my question is can the asyncio loop work cooperatively with the tkinter loop? Do I need to create a seperate thread, or is there some other solution available? Any help with this would be greatly appreciated Regards tim Sent from my iPad
While there were plans for an integrated asyncio/tkinter event loop, AFAIK nobody has done any work on it. So your best bet (unless someone else has better info) is to run asyncio in its own thread. On Sat, Sep 2, 2017 at 8:26 PM, Tim Jones via Async-sig < async-sig@python.org> wrote:
Hi I am trying to build an application on the raspberry Pi using python3.6 and tkinter for the GUI. It is an entry system for a community project and so I need to be able to receive FOB swipe data into the application which is running a tkinter user interface.
Any who I have all the components working ok but can't seem to get them to work together. I am trying to use asyncio but keep clashing with the tkinter event loop, so my question is can the asyncio loop work cooperatively with the tkinter loop?
Do I need to create a seperate thread, or is there some other solution available?
Any help with this would be greatly appreciated
Regards tim
Sent from my iPad _______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/
-- --Guido van Rossum (python.org/~guido)
2017-09-03 5:26 GMT+02:00 Tim Jones via Async-sig <async-sig@python.org>:
Hi I am trying to build an application on the raspberry Pi using python3.6 and tkinter for the GUI. It is an entry system for a community project and so I need to be able to receive FOB swipe data into the application which is running a tkinter user interface.
Any who I have all the components working ok but can't seem to get them to work together. I am trying to use asyncio but keep clashing with the tkinter event loop, so my question is can the asyncio loop work cooperatively with the tkinter loop?
Do I need to create a seperate thread, or is there some other solution available?
Any help with this would be greatly appreciated
Regards tim
Hi, Basically you have three options (from easiest to trickiest, but YMMV): 1. Use asyncio as you mainloop and do a litle task that call root.update() every 200 ms: async def gui(): root.update() await sleep(200) That has the drawback that your application will consume CPU time even when there is nothing to do. 2. Use tkinter as your mainloop and tell asyncio to use createfilehandler. You can check http://bugs.python.org/issue27546 for a way to do it. It only works on Unix, because createfilehandler is not supported on Windows 3. Use separate threads. This is tricky because you can't call any asyncio function from the tkinter thread (except call_soon_threadsafe) and you cannot call any tkinter function from the asyncio thread (exept generate_event). But it is the only way to have a proper (no polling) event loop on Windows. Regards, Maxime <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Garanti sans virus. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Hi Tim, I know I don't answer directly to your question, but we have already made a small application with AsyncIO + Quamash: https://github.com/harvimt/quamash It uses Qt for the rendering. To my little experience it works pretty well, and for my point of view, Qt rendering is nicer than tk. And Qt is LGPL since a long time ago, no more license issues like in the past. Regards. -- Ludovic Gasc (GMLudo) Lead Developer Architect at ALLOcloud https://be.linkedin.com/in/ludovicgasc 2017-09-02 23:26 GMT-04:00 Tim Jones via Async-sig <async-sig@python.org>:
Hi I am trying to build an application on the raspberry Pi using python3.6 and tkinter for the GUI. It is an entry system for a community project and so I need to be able to receive FOB swipe data into the application which is running a tkinter user interface.
Any who I have all the components working ok but can't seem to get them to work together. I am trying to use asyncio but keep clashing with the tkinter event loop, so my question is can the asyncio loop work cooperatively with the tkinter loop?
Do I need to create a seperate thread, or is there some other solution available?
Any help with this would be greatly appreciated
Regards tim
Sent from my iPad _______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/
participants (4)
-
Guido van Rossum
-
Ludovic Gasc
-
Maxime S
-
Tim Jones