[PyKDE] Whats wrong with QHeader.setLabel() ??

Anatoly V. Rudnev rudnev at dwellis.ru
Tue May 7 17:27:01 BST 2002


I'm beginner 8-((( with Python and PythonQT, but by some reasons I have to 
write Network Management Suite for KDE 

I'd like to use pixmap in rows/columns headers in a Table widget. It's 
possible? How?  Test module will fail 8-((

=== Please find python module attached to this message ( built by pyuic from 
ui file created in QT Designer)

=== Error message
Traceback (most recent call last):
  File "sql_demo", line 169, in ?
    w = MyDialog1()
  File "sql_demo", line 124, in __init__
    self.Table1.verticalHeader().setLabel(self.Table1.numRows() - 
1,image0,self.trUtf8("1"))
TypeError: Argument 2 of QHeader.setLabel() has an invalid type
Mutex destroy failure: Device or resource busy
==== End of Error message

=== Installation
OS: SuSE Linux 7.3 kernel 2.4.18-ac3
Python:	2.1.1 (#1, Oct 25 2001, 09:53:13)  (SuSE original)
KDE: 3.0.0
QT:	3.0.3
PyQT: 3.2.1

-------------------------------------------------------------------------------------------------
With best regards
Anatoly Rudnev
UNIX SysAdmin

Moscow Local Government
Department of Municipal Lodging
Information Centre "Dwelling"
Phone:  +7(095) 203-0296
Fax:       +7(095) 229-8116
-------------- next part --------------
# Form implementation generated from reading ui file 'sql_demo.ui'
#
# Created: Tue May 7 19:04:51 2002
#      by: The PyQt User Interface Compiler (pyuic)
#
# WARNING! All changes made in this file will be lost!


import sys
from qt import *
from qttable import QTable

image0_data = [
"16 16 64 1",
"# c None",
". c None",
"9 c None",
"b c #000000",
"8 c #00ff00",
"T c #303030",
"7 c #383838",
"U c #424242",
"6 c #454545",
"K c #4f4928",
"a c #574934",
"C c #585858",
"N c #646464",
"S c #666666",
"Y c #7e7e7e",
"4 c #808080",
"3 c #858585",
"2 c #898989",
"1 c #8e8e8e",
"0 c #939393",
"X c #9a9a9a",
"Q c #9b9b9b",
"u c #9d9d9d",
"M c #a0a0a0",
"L c #a1a1a1",
"R c #a5a5a5",
"t c #b7996e",
"5 c #b7b7b7",
"P c #b9b24a",
"d c #c3c3c3",
"Z c #cacaca",
"V c #dcdcdc",
"n c #dfc097",
"W c #e3e3e3",
"E c #e4cba9",
"O c #e7d2b8",
"J c #e7d3b9",
"D c #e8c08d",
"I c #e9d9c5",
"H c #ebdfcd",
"i c #ecdfcb",
"B c #ecdfcd",
"G c #ede1d1",
"F c #eee3d4",
"s c #eee5d7",
"v c #efe4d7",
"A c #f0e6d8",
"z c #f2ebe2",
"m c #f2ebe3",
"w c #f2ede4",
"e c #f3ece3",
"r c #f3ede4",
"y c #f4eee7",
"x c #f4eee8",
"q c #f5f0eb",
"l c #f5f1eb",
"j c #f6f4f0",
"k c #f7f5f3",
"p c #f7f6f4",
"h c #f7f6f5",
"f c #f7f7f6",
"o c #f8f7f6",
"g c #f8f8f8",
"c c #ffffff",
".#.#####abb#####",
"##..###accdab###",
"######befghciab#",
"######ajggklminb",
"####bbehopqrsitb",
"###buavwxyzABnb#",
"##buCtDEFGHIJCK#",
"#buLMNbtDEOnnbPK",
"buuuuQRNbSttTPK#",
"UVcWuuuXQMNbNKYb",
"UZZWVcW01234YYCb",
"bM5dZZWVcWYYYC6b",
"#bbCM5dZZWVcC67b",
"####bbCM5d8d67b#",
"##..###bbCM57b##",
"##########bbb##9"
]

class MyDialog1(QDialog):
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        QDialog.__init__(self,parent,name,modal,fl)

        image0 = QPixmap(image0_data)

        if name == None:
            self.setName("MyDialog1")

        self.resize(528,368)
        self.setCaption(self.trUtf8("MyDialog1"))
        self.setSizeGripEnabled(1)

        MyDialog1Layout = QVBoxLayout(self,11,6,"MyDialog1Layout")

        self.tabWidget = QTabWidget(self,"tabWidget")

        self.Widget8 = QWidget(self.tabWidget,"Widget8")

        self.Table1 = QTable(self.Widget8,"Table1")
        self.Table1.setNumCols(self.Table1.numCols() + 1)
        self.Table1.horizontalHeader().setLabel(self.Table1.numCols() - 1,self.trUtf8("1"))
        self.Table1.setNumCols(self.Table1.numCols() + 1)
        self.Table1.horizontalHeader().setLabel(self.Table1.numCols() - 1,self.trUtf8("2"))
        self.Table1.setNumCols(self.Table1.numCols() + 1)
        self.Table1.horizontalHeader().setLabel(self.Table1.numCols() - 1,self.trUtf8("3"))
        self.Table1.setNumRows(self.Table1.numRows() + 1)
        self.Table1.verticalHeader().setLabel(self.Table1.numRows() - 1,image0,self.trUtf8("1"))
        self.Table1.setNumRows(self.Table1.numRows() + 1)
        self.Table1.verticalHeader().setLabel(self.Table1.numRows() - 1,self.trUtf8("2"))
        self.Table1.setNumRows(self.Table1.numRows() + 1)
        self.Table1.verticalHeader().setLabel(self.Table1.numRows() - 1,self.trUtf8("3"))
        self.Table1.setGeometry(QRect(10,10,471,251))
        self.Table1.setNumRows(3)
        self.Table1.setNumCols(3)
        self.tabWidget.insertTab(self.Widget8,self.trUtf8("Tab"))

        self.Widget9 = QWidget(self.tabWidget,"Widget9")
        self.tabWidget.insertTab(self.Widget9,self.trUtf8("Tab"))
        MyDialog1Layout.addWidget(self.tabWidget)

        Layout1 = QHBoxLayout(None,0,6,"Layout1")

        self.buttonHelp = QPushButton(self,"buttonHelp")
        self.buttonHelp.setText(self.trUtf8("Help"))
        self.buttonHelp.setAccel(4144)
        self.buttonHelp.setAutoDefault(1)
        Layout1.addWidget(self.buttonHelp)
        spacer = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
        Layout1.addItem(spacer)

        self.buttonOk = QPushButton(self,"buttonOk")
        self.buttonOk.setText(self.trUtf8("OK"))
        self.buttonOk.setAccel(0)
        self.buttonOk.setAutoDefault(1)
        self.buttonOk.setDefault(1)
        Layout1.addWidget(self.buttonOk)

        self.buttonCancel = QPushButton(self,"buttonCancel")
        self.buttonCancel.setText(self.trUtf8("Cancel"))
        self.buttonCancel.setAccel(0)
        self.buttonCancel.setAutoDefault(1)
        Layout1.addWidget(self.buttonCancel)
        MyDialog1Layout.addLayout(Layout1)

        self.connect(self.buttonOk,SIGNAL("clicked()"),self,SLOT("accept()"))
        self.connect(self.buttonCancel,SIGNAL("clicked()"),self,SLOT("reject()"))


if __name__ == "__main__":
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
    w = MyDialog1()
    a.setMainWidget(w)
    w.show()
    a.exec_loop()


More information about the PyQt mailing list