[Tkinter-discuss] TKinter and Python asyncio

Bhaskar Chaudhary bha100710 at gmail.com
Thu Dec 21 02:43:59 EST 2017


In a slight modification to your code, I created the asyncio
event_loop in the main thread and passed it as an argument to the
asyncio thread. Now Tkinter won't freeze while the urls are fetched.

I have added the modified code as an answer to your stack overflow
question here:


On 12/21/17, c.buhtz at posteo.jp <c.buhtz at posteo.jp> wrote:
> X-Post:
>  <https://mail.python.org/pipermail/python-list/2017-December/729572.html>
> Dear Bhaskar,
> thank you very much for your answer and the links.
> On 2017-12-20 13:06 Bhaskar Chaudhary <bha100710 at gmail.com> wrote:
>> Here's a very simple example I borrowed from
>> http://blog.iharder.net/2017/02/03/python-asyncio-and-tkinter-together-with-tcp-and-udp/:
>> This listens for tcp messages on port 9999 and prints it to a Tkinter
>> label as and when the message arrives.
>> [..]
>> Also note that in the above example - the async i/o loop is run in a
>> separate thread. But that is just one thread to handle and it is much
>> better tan handling one new thread for every new request.
> It also came to my (and others) minds to separate each loop in it's own
> thread. But I am for a way from being a professional in that topics.
> I created a minimal working example to ask that question on
> StackOVerflow, too. There is no multithreading in that example.
> <https://stackoverflow.com/q/47895765/4865723>
> Now I modified that example "based" on your solution. But the GUI is
> still freezing why my tasks are working. Your solution is a bit to
> complex for me and use some techniques (the server think) I don't know.
> Could you please throw an eye on the current state of my code?
> <https://gitlab.com/snippets/1689797>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss

More information about the Tkinter-discuss mailing list