[PyQt] latest snapshots : pyuic4 seems to have a problem in generating Python files.

kib2 kib2 at free.fr
Wed Apr 23 18:08:23 BST 2008


Hi,

first, thanks for sharing the latest Qt4.4 support inside PyQt.
I've builded it under my Ubuntu without any problem, but I suggest that 
you put these lines inside the README :

"Edit mkspecs/common/g++.conf and comment out the line refering to 
QMAKE_LFLAGS"

Now, I've got problems with the pyuic4 utility.

I've created a main window with a WebKit widget inside.
I've launched pyuic4 like this :
	>> pyuic4 -o webkit_test.py -x webkit_test.ui

Here's the output :

 >-----------------------------------------------------------------------
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'webkit_test.ui'
#
# Created: Wed Apr 23 19:01:33 2008
#      by: PyQt4 UI code generator 4.4-snapshot-20080421
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
         MainWindow.setObjectName("MainWindow")
 
MainWindow.resize(QtCore.QSize(QtCore.QRect(0,0,818,669).size()).expandedTo(MainWindow.minimumSizeHint()))

self.centralwidget = QtGui.QWidget(MainWindow)
         self.centralwidget.setGeometry(QtCore.QRect(0,27,818,618))

sizePolicy = 
QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
         sizePolicy.setHorizontalStretch(0)
         sizePolicy.setVerticalStretch(0)
 
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
         self.centralwidget.setSizePolicy(sizePolicy)
         self.centralwidget.setSizeIncrement(QtCore.QSize(0,0))
         self.centralwidget.setObjectName("centralwidget")

self.hboxlayout = QtGui.QHBoxLayout(self.centralwidget)
         self.hboxlayout.setObjectName("hboxlayout")

self.webView = QWebView(self.centralwidget)
         self.webView.setUrl(QtCore.QUrl("http://planet.ubuntu-fr.org/"))
         self.webView.setObjectName("webView")
         self.hboxlayout.addWidget(self.webView)
         MainWindow.setCentralWidget(self.centralwidget)

self.menubar = QtGui.QMenuBar(MainWindow)
         self.menubar.setGeometry(QtCore.QRect(0,0,818,27))
         self.menubar.setObjectName("menubar")
         MainWindow.setMenuBar(self.menubar)

self.statusbar = QtGui.QStatusBar(MainWindow)
         self.statusbar.setGeometry(QtCore.QRect(0,645,818,24))
         self.statusbar.setObjectName("statusbar")
         MainWindow.setStatusBar(self.statusbar)

         self.retranslateUi(MainWindow)
         QtCore.QMetaObject.connectSlotsByName(MainWindow)

     def retranslateUi(self, MainWindow):
 
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", 
"WebKit under PyQt4", None, QtGui.QApplication.UnicodeUTF8))

from QtWebKit.QWebView import QWebView

if __name__ == "__main__":
     import sys
     app = QtGui.QApplication(sys.argv)
     MainWindow = QtGui.QMainWindow()
     ui = Ui_MainWindow()
     ui.setupUi(MainWindow)
     MainWindow.show()
     sys.exit(app.exec_())

 >-----------------------------------------------------------------------

As you can see, the resulting Python file is badly indented. I had to 
correct it by hand.

Moreover, the line "from QtWebKit.QWebView import QWebView" seems wrong.
I had to change it to "from PyQt4.QtWebKit import QWebView".

After these changes, all is working fine (the webkit widget seems to 
take a little time before appearing) as you can see here : 
http://farm3.static.flickr.com/2123/2436196113_785fa6e0f3_o.png

Can you correct this in the next release ?

Thanks,

Christophe K.


More information about the PyQt mailing list