Bartosz Telenczuk, on 2011-02-13 23:16,  wrote:
> Hi,
> 
> I am writting an application in which I update dynamically the state  
> of the figures. When I am done I call the Figure.canvas.draw function  
> to redraw the figure. However, when the window was previously closed  
> by the user the update can be skipped.
> 
> Is there a way to tell from a figure handle if the figure is shown on  
> screen or not?
> 
> Currently, I solve this problem with a callback which sets the figure  
> handle to None on figure close event. However, I guess there might be  
> a more direct way of doing that. What would you suggest?
> 
> Thanks a lot for your help.

Hi Bartosz,

I don't think there's currently a backend independent way of
doing it outside of the approach you have taken. 

Having a quick look using f = plt.gcf() before and after closing
the figure, with a WX backend, the f.canvas object changes
to an instance of <class 'wx._core._wxPyDeadObject'>, and loses
all of its usual methods.  For GTK - looks like f.canvas.window
gets set to None. 

So if you're only targeting one backend, there might be some
simple way like this to find out if a figure is being shown using
from the figure handle.

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

Attachment: signature.asc
Description: Digital signature

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to