1

I have a program that receives serial data and uses matplotlib to graph it using Tkinter. I have this working currently, but I've had to use the .after() function to poll a queue for data. In other UI frameworks I've used in the past (different projects in C) there has been a way to ask the UI framework to call a function given to it from the mainloop (either after some amount of time, during idle, etc). If I try to use .after() on a thread which isn't the mainloop, it doesn't work and complains at me.

Is there a way to call a user supplied function, provided on a thread which isn't the mainloop, from the mainloop? Or, is there a way to instruct the mainloop to wake up and do some work if a Queue gets some data?

Thanks.

kcstrom
  • 422
  • 3
  • 10

1 Answers1

1

I've heard that you can call event_generate from the non-GUI thread. If you do call event_generate, I've read that you should give the value of tail to the when parameter.

I've personally only done this in one project, but it seemed to work fine.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Thanks for this information. This is exactly what I was looking for. Googling for this, I found this other StackOverflow thread that has some more info: http://stackoverflow.com/questions/270648/tkinter-invoke-event-in-main-loop – kcstrom Mar 17 '12 at 02:53