[PyQt] [PyKDE4] Transition from PyKDE3

David Klasinc bigwhale at lubica.net
Sun May 25 20:27:05 BST 2008


Greetings,

  After some tinkering in PyKDE3, I decided that I'd rewrite everything 
in PyKDE4. To be more on the bleeding edge. ;)

I created MainWindow in designer4 and run it thru pykde4uic. Which has 
couple of bug with outputting the data, but I got past this. Then I 
created one more dialog in designer, now I'm trying to show this dialog 
when user clicks on a toolbar button. This basically the same code 
worked w/o any problems in PyKDE3. Dialogs were also designed in 
designer and then converted to .py file.

I've read the FAQ and saw this error about underlying C/C++ being 
deleted, however my code is quite similar to the one in the FAQ


PS: Creating a .ui file that is using KDE widgets in designer then 
running it through pykdeuic4 results in a broken .py file.

Instead of a line in the beginning of the file:

from PyKDE4.kdeui import KPushButton

I get:

from kpushbutton import KPushButton

at the end of the file

Code below: -----------------------------------------

main.py:

# ... about data above
mainWindow = mainWindow ()
mainWindow.show ()
app.exec_ ()


mainWindow.py:

from Ui_mainWindow import Ui_mainWindow
from addCharacter import addCharacter

class mainWindow (KMainWindow, Ui_mainWindow):
     def __init__ (self):
         KMainWindow.__init__ (self)
         self.setupUi(self)
         self.setupActions()

     def setupActions (self):
         self.addAction = KAction(KIcon("edit-clear"), i18n("Add 
Character"), self)
         self.connect(self.addAction, SIGNAL("triggered()"), 
self.addCharacter)
         self.toolBar.addAction(self.addAction)

     def addCharacter(self):
         newChar = addCharacter(self)
         newChar.show()


addCharacter.py:

from PyQt4.QtGui import QDialog
from Ui_addCharacter import Ui_addCharacter

class addCharacter (Ui_addCharacter, QDialog):

     def __init__ (self, parent):
         Ui_addCharacter.__init__(self, parent)
         print "Woo!"


---------

What did I miss?


More information about the PyQt mailing list