James K. Gruetzner wrote:
> Thanks for the suggestion, Michael.   Reading it led to a bit of a forehead
> slap.
> 
> Unfortunately, that didn't work either.  Curiously, it appears that
> the "show()" command does not return.
> 
> ----- CODE SECTION -------------
> #!/usr/local/bin/python
> 
> import os,sys
> import pylab
> 
> def main():
>   x = pylab.linspace(-10,10,100)
>   y = pylab.sin(x)
>   pylab.plot(x,y)
>   sys.stderr.write("Begun.")
>   pylab.show()
>   sys.stderr.write("Done.")
> 
> if __name__ == "__main__":
>   main()
> ---- END CODE -------------
> 
> When executed from the command line:
> $ ./test.py &
>    . . . the plot displays; clicking on the X closes it, but the process keeps
> on running.
> 
> When executed as an argument to python:
> $ python test.py &
>  . . . the same behavior (except it's a python process which hangs).
> 
> The two sys.stderr.write() statements are for debugging.  The first one
> executes; the second does not.  My conclusion is that the show() command does
> not return.
> 
> ----------
> When I operate interactively,
>   the command "pylab.plot(x,y)" opens a widow labeled "Figure 1".
>  . . . then . . .
>   the command "show()" writes the plot to that window (i.e., sine plot).
> 
> Clicking the X in the figure window causes the window to disappear, but
> the "show()" command fails to return.
> 
> --------------
> 
> So . . . I figure that the lack of show() returning is the root problem.
> 
> Any suggestions?
> 
>  I'm running Fedora 8, python 2.5.1, and matplotlib 0.91.2-1.fc8  from the yum
> repository.   Backend is set to GTKAgg in my matplotlibrc file.
> 
(On this list top-posting is frowned upon -- it makes the conversation 
difficult to follow.)

Your analysis is correct, the call to show() activates the GUI mainloop 
and does not return until the window is closed.  Within ipython there is 
some magic that occurs that runs the mainloop in a separate thread. 
What do you need to do after the call to show()?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to