[SciPy-user] Solved-ish: matplotlib, Tkinter and multi-threaded web applications
Robert Kern
robert.kern at gmail.com
Sun Oct 14 20:23:19 EDT 2007
zunzun at zunzun.com wrote:
> On Sun, Oct 14, 2007 at 05:09:36PM -0500, Robert Kern wrote:
>> Umm, only the TkAgg backend uses Tk. Why not just use a backend that doesn't
>> have a GUI? Specify
>>
>> backend : Agg
>>
>> in your .matplotlibrc or call matplotlib.use('Agg') before importing pylab.
>
> Tried it, didn't work. Tk is still started and gave a threading
> error. It might not be used, but it does start in my tests.
Please show us the code that you used on the matplotlib list. This would be a
bug. For example, I have 'WXAgg' set as the backend in my matplotlibrc, but if I
call matplotlib.use('Agg') before loading pylab, wx never gets loaded:
[~]$ ipython
Activating auto-logging. Current session state plus future input saved.
Filename : /Users/rkern/.ipython/ipython.log
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
In [1]: import sys
In [2]: 'wx' in sys.modules
Out[2]: False
In [3]: import matplotlib
In [4]: 'wx' in sys.modules
Out[4]: False
In [5]: import pylab
In [6]: 'wx' in sys.modules
Out[6]: True
In [7]:
Do you really want to exit ([y]/n)?
^[[A%
[~]$ ipython
Activating auto-logging. Current session state plus future input saved.
Filename : /Users/rkern/.ipython/ipython.log
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
In [1]: import sys
In [2]: 'wx' in sys.modules
Out[2]: False
In [3]: import matplotlib
In [4]: 'wx' in sys.modules
Out[4]: False
In [5]: matplotlib.use('Agg')
In [6]: 'wx' in sys.modules
Out[6]: False
In [7]: import pylab
In [8]: 'wx' in sys.modules
Out[8]: False
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list