나는 파이썬으로 작업 중이다. Qtdesigner에서 Gui.Py 모듈 GUI를 만들었습니다. 내가 별도로 만든 코드 모듈이 있습니다. 이제 문제가 있습니다. 코드 모듈에 while 루프를 잠깐 동안 인쇄하는 메서드가 있습니다. 내가 실시간으로이 작업을 수행 할 수있는 방법 .. 내 GUI 버튼 클릭 이벤트에서 해당 인쇄 메시지를 표시 textbrowser합니다 .. 샘플 코드는 다음과 같습니다GUI 모듈과 파이썬의 백엔드 코드 모듈의 통합
Gui..py 지금 샘플을
from 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_())
파일. 평
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()
는 제발 도와주세요, 는 근래, 대신 somefunction
를 가진 결과를 직접 인쇄하는 당신에게
감사합니다. –