tkinter bug?

Hi, All,

Sorry if this complaint appears twice on this list.

I have been using Matplotlib for a while, and I’m getting to the point where I’d like to embed the output in a Tk GUI application. I’m new to Tkinter. Here is the problem. Using the script that’s in the “examples” page on the web documentation, I run “embedding_in_tk.py”. That works. But if I uncomment the Tkinter-style “Quit” button that is at the bottom of this script, any attempt to quit using the Quit button causes the following error:

Fatal Python Error: PyEval_RestoreThread: NULL tstate

I am using clean installs of Python 2.7, numpy 1.6.1, and matplotlib 1.0.1 (all 32-bit versions running under a Win 7 64-bit OS). I have not modified the matplotlibrc. Given that this is not working “out of the box”, I’m wondering if there is a bug in FigureCanvasTkAgg or the tkagg backend in general.

A look at the archives shows a user named Jakob having a similar problem, but the solution (if any) was not posted.

Any help on this front is appreciated.

Chad

Hi, All,

Sorry if this complaint appears twice on this list.

I have been using Matplotlib for a while, and I'm getting to the point
where I'd like to embed the output in a Tk GUI application. I'm new to
Tkinter. Here is the problem. Using the script that's in the "examples"
page on the web documentation, I run "embedding_in_tk.py". That works.
But if I uncomment the Tkinter-style "Quit" button that is at the bottom
of this script, any attempt to quit using the Quit button causes the
following error:

Fatal Python Error: PyEval_RestoreThread: NULL tstate

That's probably why the button was commented out. I think the problem here is that using these gui toolkits is tricky, and the tk examples were never worked out adequately. There are various ways of putting a quit button back into the example. Try the one attached. If it works for you, I will make it replace the present example, and I will delete the embedding_in_tk2.py example because it adds nothing of interest.

Eric

embedding_in_tk.py (1.07 KB)

···

On 08/21/2011 05:54 AM, CAB wrote:

I am using clean installs of Python 2.7, numpy 1.6.1, and matplotlib
1.0.1 (all 32-bit versions running under a Win 7 64-bit OS). I have not
modified the matplotlibrc. Given that this is not working "out of the
box", I'm wondering if there is a bug in FigureCanvasTkAgg or the tkagg
backend in general.

A look at the archives shows a user named Jakob having a similar
problem, but the solution (if any) was not posted.

Any help on this front is appreciated.

Chad

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi, Eric,

Yes, the code you sent works.

Many thanks for your help!

Chad

···

From: Eric Firing <efiring@…202…>
To: matplotlib-users@…504…et
Sent: Sunday, August 21, 2011 2:05 PM
Subject: Re:
[Matplotlib-users] tkinter bug?

That’s probably why the button was commented out. I think the problem
here is that using these gui toolkits is tricky, and the tk examples
were never worked out adequately. There are various ways of putting a
quit button back into the example. Try the one attached. If it works
for you, I will make it replace the present example, and I will delete
the embedding_in_tk2.py example because it adds nothing of interest.

Eric