pyqt4: setText() inside a function

l.freschi at gmail.com l.freschi at gmail.com
Thu Apr 16 14:09:49 EDT 2009


I'm developing a PyQt4 application.

I have created a button:
...
self.start_button=QtGui.QPushButton("start simulation", self)
...

that is connected to a function:
...
self.connect(self.start_button, QtCore.SIGNAL('clicked()'),
self.simulate)
...

This is the function:
...
def simulate(self):

                self.log_inspector.setText('')
                cmds=['rm engine','make engine', './
engine']
                first_cmd="./parser "+str(self.filename)
                cmds.insert(0, first_cmd)
                for cmd in cmds:
                        self.status_inspector.setText(cmd)
                        status, output = commands.getstatusoutput(cmd)
                        output_list=output.split("\n")
                        output_list.reverse()
                        output_def="\n".join(output_list)
                        if status != 0:
                                self.log_inspector.setText(cmd"...
[ERROR]\n"+output_def)
                                return
                self.status_inspector.setText("Done!")
...

I would like to change the value of status_inspector (It's a QLabel)
during the execution of the function.
Is it possible?

I'm a newbie with PyQt and OOP!

Thank you!

Luca



More information about the Python-list mailing list