[PyKDE] Problem with pyuic and QTable

Kaercher, Joerg JKaercher at bruker-axs.com
Thu Feb 7 16:30:07 GMT 2002


Here is an example .ui file:

<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
<class>ListReflectionsUI</class>
<widget class="QDialog">
    <property name="name">
        <cstring>listReflectionsUI</cstring>
    </property>
    <property name="geometry">
        <rect>
            <x>0</x>
            <y>0</y>
            <width>916</width>
            <height>697</height>
        </rect>
    </property>
    <property name="caption">
        <string>Reflections</string>
    </property>
    <vbox>
        <property name="name">
            <cstring>unnamed</cstring>
        </property>
        <property name="margin">
            <number>11</number>
        </property>
        <property name="spacing">
            <number>6</number>
        </property>
        <widget class="QTable">
            <column>
                <property name="text">
                    <string>X</string>
                </property>
                <property name="pixmap">
                    <pixmap></pixmap>
                </property>
            </column>
            <column>
                <property name="text">
                    <string>Y</string>
                </property>
                <property name="pixmap">
                    <pixmap></pixmap>
                </property>
            </column>
            <property name="name">
                <cstring>list</cstring>
            </property>
            <property name="numRows">
                <number>0</number>
            </property>
            <property name="numCols">
                <number>2</number>
            </property>
        </widget>
        <widget class="QLayoutWidget">
            <property name="name">
                <cstring>buttonLayout</cstring>
            </property>
            <hbox>
                <property name="name">
                    <cstring>unnamed</cstring>
                </property>
                <property name="margin">
                    <number>0</number>
                </property>
                <property name="spacing">
                    <number>6</number>
                </property>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>clear</cstring>
                    </property>
                    <property name="text">
                        <string>Clear</string>
                    </property>
                    <property name="accel">
                        <number>0</number>
                    </property>
                    <property name="autoDefault">
                        <bool>true</bool>
                    </property>
                </widget>
                <spacer>
                    <property name="name" stdset="0">
                        <cstring>spacer01</cstring>
                    </property>
                    <property name="orientation">
                        <enum>Horizontal</enum>
                    </property>
                    <property name="sizeType">
                        <enum>Expanding</enum>
                    </property>
                    <property name="sizeHint">
                        <size>
                            <width>20</width>
                            <height>20</height>
                        </size>
                    </property>
                </spacer>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>ok</cstring>
                    </property>
                    <property name="text">
                        <string>&amp;OK</string>
                    </property>
                    <property name="accel">
                        <number>276824143</number>
                    </property>
                    <property name="autoDefault">
                        <bool>true</bool>
                    </property>
                    <property name="default">
                        <bool>true</bool>
                    </property>
                </widget>
                <widget class="QPushButton">
                    <property name="name">
                        <cstring>cancel</cstring>
                    </property>
                    <property name="text">
                        <string>&amp;Cancel</string>
                    </property>
                    <property name="accel">
                        <number>276824131</number>
                    </property>
                    <property name="autoDefault">
                        <bool>true</bool>
                    </property>
                </widget>
            </hbox>
        </widget>
    </vbox>
</widget>
<connections>
    <connection>
        <sender>ok</sender>
        <signal>clicked()</signal>
        <receiver>listReflectionsUI</receiver>
        <slot>accept()</slot>
    </connection>
    <connection>
        <sender>cancel</sender>
        <signal>clicked()</signal>
        <receiver>listReflectionsUI</receiver>
        <slot>reject()</slot>
    </connection>
    <connection>
        <sender>clear</sender>
        <signal>clicked()</signal>
        <receiver>listReflectionsUI</receiver>
        <slot>_onClearAllReflections()</slot>
    </connection>
</connections>
<slots>
    <slot access="protected">_onClearAllReflections()</slot>
    <slot access="protected">_onOK()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

The .py file created by pyuic is:

# Form implementation generated from reading ui file './nixui.ui'
#
# Created: Thu Feb 7 10:31:21 2002
#      by: The PyQt User Interface Compiler (pyuic)
#
# WARNING! All changes made in this file will be lost!
 
 
import sys
from qt import *
 
 
class ListReflectionsUI(QDialog):
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        QDialog.__init__(self,parent,name,modal,fl)
 
        if name == None:
            self.setName("listReflectionsUI")
 
        self.resize(916,697)
        self.setCaption(self.trUtf8("Reflections"))
 
        listReflectionsUILayout =
QVBoxLayout(self,11,6,"listReflectionsUILayout")
 
        self.list = QTable(self,"list")
        self.list.setNumCols(self.list.numCols() + 1)
self.list.horizontalHeader().setLabel(self.list.numCols() -
1,self.trUtf8("X"))
        self.list.setNumCols(self.list.numCols() + 1)
self.list.horizontalHeader().setLabel(self.list.numCols() -
1,self.trUtf8("Y"))
        self.list.setNumRows(0)
        self.list.setNumCols(2)
        listReflectionsUILayout.addWidget(self.list)
 
        buttonLayout = QHBoxLayout(None,0,6,"buttonLayout")
 
        self.clear = QPushButton(self,"clear")
        self.clear.setText(self.trUtf8("Clear"))
        self.clear.setAccel(0)
        self.clear.setAutoDefault(1)
        buttonLayout.addWidget(self.clear)
        spacer =
QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
        buttonLayout.addItem(spacer)
 
        self.ok = QPushButton(self,"ok")
        self.ok.setText(self.trUtf8("&OK"))
        self.ok.setAccel(276824143)
        self.ok.setAutoDefault(1)
        self.ok.setDefault(1)
        buttonLayout.addWidget(self.ok)
 
        self.cancel = QPushButton(self,"cancel")
        self.cancel.setText(self.trUtf8("&Cancel"))
        self.cancel.setAccel(276824131)
        self.cancel.setAutoDefault(1)
        buttonLayout.addWidget(self.cancel)
        listReflectionsUILayout.addLayout(buttonLayout)
 
        self.connect(self.ok,SIGNAL("clicked()"),self,SLOT("accept()"))
        self.connect(self.cancel,SIGNAL("clicked()"),self,SLOT("reject()"))
 
self.connect(self.clear,SIGNAL("clicked()"),self._onClearAllReflections)
 
    def _onClearAllReflections(self):
        print "ListReflectionsUI._onClearAllReflections(): Not implemented
yet"
 
    def _onOK(self):
        print "ListReflectionsUI._onOK(): Not implemented yet"
 
 
if __name__ == "__main__":
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
    w = ListReflectionsUI()
    a.setMainWidget(w)
    w.show()
    a.exec_loop()

> -----Original Message-----
> From:	Phil Thompson [SMTP:phil at river-bank.demon.co.uk]
> Sent:	Thursday, February 07, 2002 3:19 AM
> To:	Kaercher, Joerg
> Cc:	pykde at mats.gmd.de
> Subject:	Re: [PyKDE] Problem with pyuic and QTable
> 
> "Kaercher, Joerg" wrote:
> > 
> > Hi,
> > 
> > I noticed two problems with the pyuic from PyQt v3.0 (patches 1 through
> 4)
> > when using a QTable widget:
> > 1) 'from qttable import *' is missing and thus the QTable class is not
> > found.
> > 2) The calls to 'setNumCols()' and 'horizontalHeader().setLabel()'
> appear on
> > the same line without a semicolon in between.
> > Both cases generate a runtime error in Python.
> 
> Can you send me a .ui file that demonstrates the bugs?
> 
> Phil




More information about the PyQt mailing list