[PyKDE] First Python QT app queries
Dave S
eric3 at pusspaws.net
Tue Jul 18 20:39:17 BST 2006
Hi all,
This is my first attempt at combining Python & QT - Thanks to eric its
relatively painless :) but I have a couple of queries.
(1) When I execute my dialogue script I have to
'python dlg_livedata.py', If I ...
'./dlg_livedata.py'
as I normally do I get a wierd X cursor. What is happening, I thought with
a '#!/bin...python' both statements were the same ?
(2) When I start my dialogue script I get warnings from BASH ...
ubuntu at ubuntu:~/python_develop/unison/DDC/QT$ python dlg_livedata.py
X Error: BadDevice, invalid or uninitialized input device 168
Major opcode: 145
Minor opcode: 3
Resource id: 0x0
Failed to open device
X Error: BadDevice, invalid or uninitialized input device 168
Major opcode: 145
Minor opcode: 3
Resource id: 0x0
Failed to open device
Am I doing something wrong or is this normal ?
(3) I would like my boxes to stretch if I full screen the window. They stay
the same size - I have looked in qt designer but max size is already set to
32767 - what do I have to do to allow stretching ?
(4) When I made my QlistBox I deleted all items. In qt designer preview it
looks perfect. When I write to the list box ie ...
'win.listBox2.insertItem(mapdata)'
I get a this line below the top line. How do I delete it ?
Cheers
Dave
*********************************************
from QT designer ....
import sys
from qt import *
class frm(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)
if not name:
self.setName("DDC:Daemon_Monitor")
self.setEnabled(1)
self.setPaletteForegroundColor(QColor(0,0,0))
self.frame3_2 = QFrame(self,"frame3_2")
self.frame3_2.setGeometry(QRect(20,100,100,60))
self.frame3_2.setFrameShape(QFrame.StyledPanel)
self.frame3_2.setFrameShadow(QFrame.Raised)
self.textLabel3_2 = QLabel(self.frame3_2,"textLabel3_2")
self.textLabel3_2.setEnabled(0)
self.textLabel3_2.setGeometry(QRect(10,10,80,37))
self.frame3_2_2 = QFrame(self,"frame3_2_2")
self.frame3_2_2.setGeometry(QRect(20,170,100,60))
self.frame3_2_2.setFrameShape(QFrame.StyledPanel)
self.frame3_2_2.setFrameShadow(QFrame.Raised)
self.textLabel3_3 = QLabel(self.frame3_2_2,"textLabel3_3")
self.textLabel3_3.setEnabled(0)
self.textLabel3_3.setGeometry(QRect(10,10,80,37))
self.frame3_2_3 = QFrame(self,"frame3_2_3")
self.frame3_2_3.setGeometry(QRect(20,240,100,60))
self.frame3_2_3.setFrameShape(QFrame.StyledPanel)
self.frame3_2_3.setFrameShadow(QFrame.Raised)
self.textLabel3_4 = QLabel(self.frame3_2_3,"textLabel3_4")
self.textLabel3_4.setEnabled(0)
self.textLabel3_4.setGeometry(QRect(10,10,80,37))
self.frame3 = QFrame(self,"frame3")
self.frame3.setGeometry(QRect(20,30,100,60))
self.frame3.setFrameShape(QFrame.StyledPanel)
self.frame3.setFrameShadow(QFrame.Raised)
self.textLabel3 = QLabel(self.frame3,"textLabel3")
self.textLabel3.setEnabled(0)
self.textLabel3.setGeometry(QRect(10,10,80,37))
self.listBox2 = QListBox(self,"listBox2")
self.listBox2.setGeometry(QRect(130,30,660,271))
self.listBox2.setPaletteBackgroundColor(QColor(232,255,255))
self.listBox2.setVariableWidth(1)
self.languageChange()
self.resize(QSize(814,332).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)
def languageChange(self):
self.setCaption(self.__tr("DDC Monitor","A monitor"))
self.textLabel3_2.setText(self.__tr("<p align=\"center\">Sleeping\n"
"</p>"))
self.textLabel3_3.setText(self.__tr("<p align=\"center\">Download\n"
"</p>"))
self.textLabel3_4.setText(self.__tr("<p align=\"center\">Process\n"
"Data</p>"))
self.textLabel3.setText(self.__tr("<p align=\"center\">Daemon\n"
"Running</p>"))
def __tr(self,s,c = None):
return qApp.translate("frm",s,c)
if __name__ == "__main__":
a = QApplication(sys.argv)
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
w = frm()
a.setMainWidget(w)
w.show()
a.exec_loop()
More information about the PyQt
mailing list