PDA

View Full Version : qt4 designer and python



raymando
November 5th, 2009, 04:33 PM
I want to use my gui's I create with qt4 designer in python. I convert it using pykdeuic4, but I can't really find any tutorial explaining the script created by pyuic. I can find info about pyqt4, creating windows, buttons, etc. but not about the code pyuic creates. Can anybody help me a bit?
Here is the script for a window with a button, created in pyqt4 designer, converted with pykdeuic4 to python:

#!/usr/bin/env python
# coding=UTF-8
#
# Generated by pykdeuic4 from Desktop/bash/untitleda1a.ui on Thu Nov 5 16:26:56 2009
#
# WARNING! All changes to this file will be lost.
from PyKDE4 import kdecore
from PyKDE4 import kdeui
from PyQt4 import QtCore, QtGui

class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(130, 100, 99, 29))
self.pushButton.setObjectName("pushButton")

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

def retranslateUi(self, Dialog):
Dialog.setWindowTitle(kdecore.i18n("Dialog"))
self.pushButton.setText(kdecore.i18n("test"))


While I would do:

#!/usr/bin/python

import sys
from PyQt4 import QtGui, QtCore


class QuitButton(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)

quit = QtGui.QPushButton('test', self)
quit.setGeometry(10, 10, 60, 35)


app = QtGui.QApplication(sys.argv)
qb = QuitButton()
qb.show()
sys.exit(app.exec_())

I don't really understand the code pykdeuic4 creates, and on the internet I can't find anything.

raymando
November 5th, 2009, 09:52 PM
...