[IPython-user] Starting wx python apps

Gökhan SEVER gokhansever@gmail....
Fri Jun 26 16:47:48 CDT 2009


On Fri, Jun 26, 2009 at 3:44 PM, Gökhan SEVER <gokhansever@gmail.com> wrote:

> On Fri, Jun 26, 2009 at 3:29 PM, Dennis Muhlestein <djmuhlestein@gmail.com
> > wrote:
>
>>
>>  Interesting.
>>>
>>> On my Fedora, plot doesn't block the Ipython entry. They happily live by
>>> eachother.
>>>
>>> One thing I modified in the Shell.py (inside IPython folder) is to make
>>> sure that I am always starting with pylab:
>>>
>>>     #user_opts = set([s.replace('-','') for s in argv[:3]])
>>>     user_opts = set(['pylab'])
>>>
>>> Could you try with this?
>>>
>>
>> I didn't modify this file, but I'm pretty sure this would cause the Show
>> function to not block since if I start ipython with -pylab, I can verify the
>> non-blocking feature.
>>
>> My problem is that -pylab and -wthread don't work the same way.
>>
>> ipython -pylab pylab_script.py # __doesn't__ block
>> ipython -wthread wx_script.py # __does__ block
>>
>> It would be nice if -wthread worked the same as -pylab
>>
>> -Dennis
>>
>
> I see your point now.
>
> wthread switch blocks the execution somehow, however q4thread works well.
>
> There should be some internal differences between the backends that is
> causing this issue.
>
> And a very interesting observation if I run the following lines with
> q4thread
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> a = np.linspace(0,2*np.pi, 1000)
> plt.plot(np.sin(a))
> plt.show()
>
> I see the contents listed on whos, but get a empty namespace if I try the
> same thing with wthread.
>
> One additional comment: The ipy.py script was explicitly calling the
> ipython from within a regular python script. I might not need to this if my
> scripts load into an Ipython workspace with just a ipython script.py
> notation


I am going to ask a question (sorry for hijacking your thread Dennis -- I
know your question and mine has answers somewhere in Shell.py, however
haven't figured out yet. Maybe someone more experienced could comment on
this time)

A very simple snippet (in my case in test.py):

import matplotlib.pyplot as plt

a = range(10)
plt.plot(a)
plt.show()

If I call it as:
ipython -q4thread test.py

[gsever@ccn Desktop]$ ipython -q4thread test.py
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
Type "copyright", "credits" or "license" for more information.

IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: whos
Variable   Type      Data/Info
------------------------------
a          list      [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
plt        module    <module 'matplotlib.pyplo<...>b/matplotlib/pyplot.pyc'>

As seen above whos works as I desired.



But, if I call with pylab switch:

[gsever@ccn Desktop]$ ipython -pylab test.py

Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
Type "copyright", "credits" or "license" for more information.

IPython 0.10.bzr.r1174 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: whos
Interactive namespace is empty.

Heh, nothing is visible on the namespace.


If I can make pylab entry works as q4thread I will not need to put the
following lines into my scripts and no extra modifies in Shell.py to start
with pylab each time:

import IPython
ipy = IPython.Shell.start(user_ns=locals())
ipy.mainloop()

Thanks,
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20090626/04ff9bd5/attachment-0001.html 


More information about the IPython-user mailing list