From: VC <va...@gm...> - 2009-04-01 23:44:23
|
Hi all, I am experiencing the following difficulty: My program basically loops and wants to redraw a plot (using imshow() ) every 5 seconds or so. So it looks something like: ion() while 1: do redraw business.. time.sleep(5) The redrawing shows up fine, the only problem is that during the 5 seconds of sleep, I cannot really move the figure window or really do anything with it. I am using MPL on windows with the 'Qt4Agg' backed, and running this code from ipython (on the command line). I don't quite understand the threading model of the GUI kit, vs. the main thread, so could someone enlighten me how it works roughly, and what I need to do in a multi-threaded application in order to update a figure periodically, and be able to move it around, and do things with its figure window. Thanks in advance for any responses. |
From: Jae-Joon L. <lee...@gm...> - 2009-04-02 20:59:53
|
I guess you're using ipython in pylab mode, correct? If you want to make a standalone application, I recommend you not to use ipython pylab mode. Instead, use your own gui toolkit. Take a look at following examples. http://matplotlib.sourceforge.net/examples/user_interfaces/index.html However, a quick solution in your case would be using canvas = gcf().canvas canvas.start_event_loop(timeout=10) instead of time.sleep. In ipython pylab mode, the mainloop of the gui backend is blocked while your command is running (e.g., time.sleep function in your example, Tk is the only exception I know). To have your figure canvas responsive while you're running your code, the code you're running need to explicitly process the gui event of the canvas (this is what start_event_loop in above example is for). Again, start_event_loop may be used in your case for a quick solution, but I personally recommend you to develop within the framework of your gui choice (matplotlib does have its own gui-neutral event model, but I don't think a timeout event is supported). IHTH, -JJ On Wed, Apr 1, 2009 at 7:44 PM, VC <va...@gm...> wrote: > Hi all, > > I am experiencing the following difficulty: > > My program basically loops and wants to redraw a plot (using imshow() ) > every 5 seconds or so. So it looks something like: > > ion() > while 1: > do redraw business.. > time.sleep(5) > > The redrawing shows up fine, the only problem is that during the 5 seconds > of sleep, I cannot really move the figure window or really do anything with > it. > > I am using MPL on windows with the 'Qt4Agg' backed, and running this code > from ipython (on the command line). I don't quite understand the threading > model of the GUI kit, vs. the main thread, so could someone enlighten me how > it works roughly, and what I need to do in a multi-threaded application in > order to update a figure periodically, and be able to move it around, and do > things with its figure window. > > Thanks in advance for any responses. > ------------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
From: VGC123 <va...@gm...> - 2009-04-07 15:05:00
|
Thanks a lot, Jae. Your suggestion was very helpful. Jae-Joon Lee wrote: > > I guess you're using ipython in pylab mode, correct? > If you want to make a standalone application, I recommend you not to > use ipython pylab mode. > Instead, use your own gui toolkit. Take a look at following examples. > > http://matplotlib.sourceforge.net/examples/user_interfaces/index.html > > However, a quick solution in your case would be using > > canvas = gcf().canvas > canvas.start_event_loop(timeout=10) > > instead of time.sleep. > > > In ipython pylab mode, the mainloop of the gui backend is blocked > while your command is running (e.g., time.sleep function in your > example, Tk is the only exception I know). To have your figure canvas > responsive while you're running your code, the code you're running > need to explicitly process the gui event of the canvas (this is what > start_event_loop in above example is for). > > Again, start_event_loop may be used in your case for a quick solution, > but I personally recommend you to develop within the framework of your > gui choice (matplotlib does have its own gui-neutral event model, but > I don't think a timeout event is supported). > > IHTH, > > -JJ > > > > On Wed, Apr 1, 2009 at 7:44 PM, VC <va...@gm...> wrote: >> Hi all, >> >> I am experiencing the following difficulty: >> >> My program basically loops and wants to redraw a plot (using imshow() ) >> every 5 seconds or so. So it looks something like: >> >> ion() >> while 1: >> do redraw business.. >> time.sleep(5) >> >> The redrawing shows up fine, the only problem is that during the 5 >> seconds >> of sleep, I cannot really move the figure window or really do anything >> with >> it. >> >> I am using MPL on windows with the 'Qt4Agg' backed, and running this >> code >> from ipython (on the command line). I don't quite understand the >> threading >> model of the GUI kit, vs. the main thread, so could someone enlighten me >> how >> it works roughly, and what I need to do in a multi-threaded application >> in >> order to update a figure periodically, and be able to move it around, and >> do >> things with its figure window. >> >> Thanks in advance for any responses. >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > > ------------------------------------------------------------------------------ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://www.nabble.com/Being-able-to-move-figure-around-during-time.sleep%28%29-tp22838236p22931234.html Sent from the matplotlib - users mailing list archive at Nabble.com. |