Re: Plotting to a matplotlib / pyplot window does not work
Andrea Gavana <[email protected]>
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <CAEf70bw8KpGynxbmPvYRpC17Pz9GgM8dQkLsCwLOsgRX6-Mj1w@mail.gmail.com> |
On Thu, 23 Jul 2020 at 13:42, Matthias Brennwald <[email protected]> wrote: > On Do, Jul 23, 2020 at 13:05, Andrea Gavana <[email protected]> > wrote: > > I also have an application that does heavy calculations in a separate > thread and updates the main plotting window at selected timesteps. > Depending on the model, I may get between 1 and 100 results per second and > I have to update the plot with that. > > > Speeding up the plotting part is certainly useful. > > However, my question was more related to how it would be possible to avoid > the situation that the GUI may lock up. I guess the issue is that in my > code example the calls to wx.CallLater( ...update_the_plot... ) are piling > up, and therefore the queue is blocking all other code that would be called > to handle the GUI. Since I am a newbie to wxPython I would be surprised if > there weren't a few better ways than what I did my example. Maybe there is > a mechanism that avoids the wx.CallLater(...) from piling up, or something > else than wx.CallLater(...) entirely. > I suggest you use wx.CallAfter instead of wx.CallLater. If the plotting part is relatively quick, there shouldn't be any pile-up of events, unless the rate of data coming in from your instrument exceeds the FPS of your plotting. At that point the GUI is busy plotting stuff only, which is not good. If you have a very high rate of wx.CallAfter stuff coming in, then I suggest you update the plot every N times instead of every time something comes in. Andrea. -- You received this message because you are subscribed to the Google Groups "wxPython-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/CAEf70bw8KpGynxbmPvYRpC17Pz9GgM8dQkLsCwLOsgRX6-Mj1w%40mail.gmail.com.