[PyQt] small test crashing

Marcos Dione mdione at grulic.org.ar
Sun Dec 12 11:21:52 GMT 2010

    trying to find if there was anything wrong with KAction (I have a piece of
code that uses a global shortcut, but it's not working) I scrambled this small 

---cut here---
from PyKDE4.kdecore import KCmdLineArgs, KAboutData, i18n, ki18n
from PyKDE4.kdeui import KApplication
from PyKDE4.kdeui import KXmlGuiWindow, KGlobalSettings, KActionCollection
from PyKDE4.kdeui import KAction, KShortcut
from PyQt4.QtCore import Qt
from PyQt4.QtCore import pyqtSignal
import sys

class Win (KXmlGuiWindow):

    finished= pyqtSignal ()

    def result (self):
        print ("Win.result(): ping!");
        self.finished.emit ()

def main (args=sys.argv):
    appName     = "foo"
    catalog     = ""
    programName = ki18n ("foo")                 #ki18n required here
    version     = ""
    description = ki18n ("moo")         #ki18n required here
    license     = KAboutData.License_GPL
    copyright   = ki18n ("(c) 2009, 2010 Marcos Dione")    #ki18n required here
    text        = ki18n ("none")                    #ki18n required here
    homePage    = ""
    bugEmail    = "mdione at grulic.org.ar"

    aboutData   = KAboutData (appName, catalog, programName, version, description,
                                license, copyright, text, homePage, bugEmail)

    KCmdLineArgs.init (args, aboutData)

    app= KApplication ()

    win= Win ()
    action= KAction ("foo/man/chu", win)
    action.setObjectName ("foo/man/chu")
    action.setGlobalShortcut (KShortcut (Qt.Key_MediaNext))
    win.actionCollection().addAction ("satyr.player.net", action)
    action.triggered.connect (win.result)

    win.show ()

    win.finished.connect (app.quit)
    return app.exec_ ()

main ()
---cut here---

    this example crashes when the signal is fired. I feel that this is not
a bug in PyQt4/PyKDE4, but an error in the ways I use it. like not knowing
some "do no t do this" gideline. am I missing something? FYI, this is Debian
Sid with all official packages as of last thursday.

(Not so) Random fortune:
merging with svn seems to always be an "Oh good Lord! We have to MERGE!" event
	    -- Mike Fletcher.

More information about the PyQt mailing list