interactive pylab graphics

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
wwlytton
Posts: 65
Joined: Wed May 18, 2005 10:37 pm
Contact:

interactive pylab graphics

Post by wwlytton » Sat Dec 11, 2010 11:36 am

matplotlib offers interactive graphics through setting of variables in ~/.matplotlib/matplotlibrc

backend : TkAgg
interactive : True

(see matplotlib.sourceforge.net/users/shell.html)

This works from a regular python shell but does not seem to work from the python shell spawned by 'nrniv -python'

python # works in this example
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from matplotlib import pylab
>>> pylab.plot([1,2,1])
[<matplotlib.lines.Line2D object at 0x23ed2d0>]
>>> pylab.xlabel('hello world')
<matplotlib.text.Text object at 0x2084d90>

nrniv -python # fails here
NEURON -- VERSION 7.2 (485:31e0fdb95950) 2010-11-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html
>>> from matplotlib import pylab
>>> pylab.plot([1,2,1]) # nothing appears
[<matplotlib.lines.Line2D object at 0x1bd50d0>]
>>> pylab.show() # graph appears but then no prompt

hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: interactive pylab graphics

Post by hines » Sun Dec 12, 2010 6:47 am

The matrix of possibilities for (nrniv - python , python) and (InterViews, Python graphics)
is filled in only for three of the four possibilities.
nrniv -python uses InterViews
python uses Python and if "from neuron import gui" is executed then a .1 second timing loop will allow InterViews to work as well.
(Note do not use the timer when launching nrniv as a crash will likely result, perhaps due to hoc being executed withing different
threads.)

So to get python graphics from "nrniv -python" one possibility would be to use a timer which does an event handler step
for the python graphics.

The question is always: who is managing the gui event loop.

Post Reply