[PyKDE] setText of all LineEdits with button click
Bill Burns
billburns at pennswoods.net
Sat Sep 25 15:16:20 BST 2004
I'm trying to make one button click set the text to "hi" on all four LineEdits
in the code below. So far I'm able to pass the string "hi" to the function
set() in the class MyLineEdit but it will not set the text of the LineEdits.
What am I doing wrong?
I'm not a programmer. I just found PyQt about two weeks ago, found it
fascinating and have been "tooling" around with it every since!
TIA
Bill
Here are some of my specifications:
Suse 9.1
kernel-default-2.6.5-7.108
python-2.3.3-85
qt3-3.3.1-36.16
PyQt-3.11-17
sip-3.10.1-16
Here's the code I'm trying to make work:
#!/usr/bin/env python
import os
import sys
from qt import *
class MyLineEdit(QLineEdit):
def __init__(self, parent):
QLineEdit.__init__(self, parent)
def set(self, txt):
#print txt
self.setText(txt)
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.grid=QGrid(2, self)
self.grid.setFrameShape(QFrame.StyledPanel)
self.setCentralWidget(self.grid)
self.le0=MyLineEdit(self.grid)
self.le1=MyLineEdit(self.grid)
self.le2=MyLineEdit(self.grid)
self.le3=MyLineEdit(self.grid)
self.bn1=QPushButton("Set Text", self.grid)
self.connect(self.bn1, SIGNAL("clicked()"), self.setLineEdit)
def setLineEdit(self):
MyLineEdit(self).set("hi")
def main(args):
app=QApplication(args)
win=MainWindow()
win.show()
app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
app.exec_loop()
if __name__=="__main__":
main(sys.argv)
More information about the PyQt
mailing list