[IPython-user] ipython qt4 bug?

Darren Dale darren.dale@cornell....
Thu Feb 7 09:50:07 CST 2008


I was wrong. It turns out that, as of version 4.2.1, PyQt4 makes use of 
PyOS_InputHook to provide similar behavior to Tkinter when using an 
interactive interpreter. An example is given at 
http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#using-pyqt-from-the-python-shell :

>>> from PyQt4 import QtGui
>>> a = QtGui.QApplication([])
>>> w = QtGui.QWidget()
>>> w.show()
>>> w.hide()
>>>

I tried playing around with this, modifying Shell.py to prevent the ipython 
and PyQt from conflicting by using the standard IPShell and IPShellMatplotlib 
for both --tkthread, --q4thread and the tk and qt4 matplotlib backends. This 
seemed to work well for ipython -pylab. 

Calls to exec_(), however, still block with PyQt's implementation, but not 
with IPython's. Fortunately Phil Thompson provided methods to disable PyQt's 
implementation, which silence the error messages you observed with cpaste. I 
checked in this change in svn-3024.

Darren

On Tuesday 05 February 2008 01:35:35 pm humufr@yahoo.fr wrote:
> Oki thank you I hope that will be solved/corrected in a next pyqt4 version.
>
> N.
>
> Le Tuesday 05 February 2008 09:23:13, vous avez écrit :
> > I'm almost 100% positive this is a problem in PyQt4. We had a similar
> > problem with QApplication.exec, which got ironed out when PyQt-4.2 (I
> > think it was 4.2) was released. I'll ask about it on the PyQt mailing
> > list.
> >
> > Darren
> >
> > On Monday 04 February 2008 05:58:59 pm humufr@yahoo.fr wrote:
> > > 		Hello,
> > >
> > > With the last ipython svn I have a problem to use the magic command
> > > cpaste. It's working fine with qt3 or the default thread but the
> > > problem is there if you are trying to use qt4 for backend in pylab.
> > >
> > > Here you'll find the output.
> > >
> > > The error is there because I did an ctrl-d to stop the loop with the
> > > error message on the loop.
> > >
> > > Thanks
> > >
> > > N.
> > >
> > > > ipython --q4thread
> > >
> > > Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
> > > Type "copyright", "credits" or "license" for more information.
> > >
> > > IPython 0.8.3.svn.r3001 -- 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]: cpaste
> > > Pasting code; enter '--' alone on the line to stop.
> > >
> > > :QCoreApplication::exec: The event loop is already running
> > >
> > > QCoreApplication::exec: The event loop is already running
> > > QCoreApplication::exec: The event loop is already running
> > > QCoreApplication::exec: The event loop is already running
> > > QCoreApplication::exec: The event loop is already running
> > > QCoreApplication::exec: The event loop is already running
> > > QCoreApplication::exec: The event loop is already running
> > > -----------------------------------------------------------------------
> > >-- -- EOFError                                  Traceback (most recent
> > > call last)
> > >
> > > <ipython console> in <module>()
> > >
> > > /usr/lib/python2.5/site-packages/IPython/iplib.pyc in ipmagic(self,
> > > arg_s) 951         else:
> > >     952             magic_args = self.var_expand(magic_args,1)
> > > --> 953             return fn(magic_args)
> > >     954
> > >     955     def ipalias(self,arg_s):
> > >
> > > /usr/lib/python2.5/site-packages/IPython/Magic.pyc in
> > > magic_cpaste(self, parameter_s)
> > >    3149         print "Pasting code; enter '%s' alone on the line to
> > > stop." % sentinel
> > >    3150         while 1:
> > > -> 3151             l = iplib.raw_input_original(':')
> > >    3152             if l ==sentinel:
> > >    3153                 break
> > >
> > > EOFError:
> > > _______________________________________________
> > > IPython-user mailing list
> > > IPython-user@scipy.org
> > > http://lists.ipython.scipy.org/mailman/listinfo/ipython-user



-- 
Darren S. Dale, Ph.D.
Staff Scientist
Cornell High Energy Synchrotron Source
Cornell University
275 Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

darren.dale@cornell.edu
office: (607) 255-3819
fax: (607) 255-9001
http://www.chess.cornell.edu


More information about the IPython-user mailing list