Ich arbeite in Python. Ich habe eine GUI in Qtdesigner in einem Modul Gui.Py erstellt. Ich habe ein Code-Modul, das ich separat erstellt habe. Jetzt gibt es ein Problem, ich habe eine Methode in meinem Code-Modul, die für einige Zeit in While-Schleife druckt. Ich möchte, dass meine gui Textbrowser in Schaltfläche klicken Ereignis, das Drucknachricht angezeigt werden .. Wie kann ich dies tun in Echtzeit .. Der Beispielcode ist:Integration von GUI-Modul mit Backend-Code-Modul in Python
Gui..py
Dateifrom PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(400, 211)
self.textBrowser = QtGui.QTextBrowser(Form)
self.textBrowser.setGeometry(QtCore.QRect(140, 10, 256, 192))
self.textBrowser.setObjectName(_fromUtf8("textBrowser"))
self.pushButton = QtGui.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(20, 80, 97, 27))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("Form", "PushButton", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
Jetzt Probe. py
import time
class A:
def somefunction(self):
i=0
while i<100:
print str(i)
i+=1
time.sleep(2)
if __name__=='__main__':
p=A()
p.somefunction()
Bitte helfen Sie mir, Danke
Vielen Dank, ich habe es :) –