PySide: python IDLE lacks compatibility



  • PySide shows great promise. It would help if it was able to repeat running of programs in IDLE editor window. Currently it is possible to run a program from IDLE editor window once, but attempt to repeat the run in the same session fails, because IDLE complains alleging that QApplication is already running. This makes IDLE not useful as editor for PySide program development.

    A brief example:

    A program from IDLE editor window:


    from PySide.QtGui import QApplication
    import sys

    print 'trying to use python-idle for PySide'
    app = QApplication(sys.argv)


    And now results of attempting to run it twice:


    IDLE 2.6.6 ==== No Subprocess ====

    trying to use python-idle for PySide

    trying to use python-idle for PySide
    Traceback (most recent call last):
    File "/home/ak/show_idle_bug.py", line 5, in <module>
    app = QApplication(sys.argv)
    RuntimeError: A QApplication instance already exists.


    Any suggestions how to enable IDLE to edit PySide based programs during several development stages? Eric also raises some issues. vi works, as do other pure text editors, but it would be easier if an interactive editor with de-bugging facilities was accessible.

    OldAl



  • Humm, I think it's not a pyside problem, but it's a IDLE issue.

    Does it happens with pyqt too? I believe IDLE keeps the QApplication instance alive for every python bind of qt... And, as you know, you can't have two instances of qapp in the same application.



  • Maybe one of the following will help:

    @app = None@
    @del app@

    Both should remove the reference to the QApplication. Because Python is garbage collected you cannot assume it is actually cleaned up there, so you might have to look for other places where the app is referenced.



  • [quote author="danilocesar" date="1288615082"]Humm, I think it's not a pyside problem, but it's a IDLE issue.
    .[/quote]
    I do not think we can blame IDLE - it works fine with Python (including PyQt4) programs - and has been doing that well for a long, long time! It works fine with PyQt4, but screws up with PySide. Does not sound like an IDLE fault to me. Here is another example with two sets of answers - one when PySide is used, the other when PyQt4 is used.
    [CODE]
    #!/usr/bin/env python
    '''show_idle_bug.py - no parameters'''

    ##flag = True
    flag = False

    if flag:
    from PySide.QtGui import QApplication
    else:
    import sip
    sip.setapi("QApplication", 2)
    from PyQt4.QtGui import QApplication
    import sys

    for i in range(10):
    print "flag = %s" % (flag)
    app = QApplication(sys.argv)

    -----------------------------------------------

    ##Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
    ##[GCC 4.4.5] on linux2
    ##Type "copyright", "credits" or "license()" for more information.
    ##IDLE 2.6.6

    -----------------------------------------------

    ##>>>
    ##flag = True
    ##flag = True
    ##Traceback (most recent call last):

    File "/home/ak/show_idle_bug.py", line 16, in <module>

    app = QApplication(sys.argv)

    ##RuntimeError: A QApplication instance already exists.
    ##>>>

    ------------------------------------------------

    ##>>>
    ##flag = False
    ##flag = False
    ##flag = False
    ##flag = False
    ##flag = False
    ##flag = False
    ##flag = False
    ##flag = False
    ##flag = False
    ##flag = False
    ##>>>

    -----------------------------------------------

    [/CODE]

    OldAl - unhappy :(



  • [quote author="Franzk" date="1288678762"]Maybe one of the following will help:

    @app = None@
    @del app@
    [/quote]

    I've tried that without much joy, but thanks a lot for a sensible suggestion. Because of a different PySide glitch, Eric will not work satisfactorily with PySide programs in the debug stage. So the two main Python editors are not available with PySide - an unwelcome limitation IMHO. It is not critical, I can work fine with Kate or even vi, but it adds an unnecessary additional burden.

    Who "hears the cries of the poor"?

    OldAl.



  • Well, if PyQt does this, its behavior is slightly different from the official QApplication documentation.

    Anyway, you can always create a feature request (or bug ?) on "pyside's bugzilla":http://bugs.openbossa.org/.

    "Who “hears the cries of the poor”?" - pyside developers are playing around here for a while. =)



  • The fact that QCoreApplication behaves somewhat like a Singleton is bugging me. Although it is obviously sensible to have only one instance of a QCoreApplication around, I can't help but feel that there would be a much more reasonable way to make this work. I mean, if I want to try and drive two cars at the same time, it's the police who will try to stop me, not the car.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.