测试模板.py:
from PySide import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(153, 130)
self.testlabel = QtGui.QLabel(Dialog)
self.testlabel.setGeometry(QtCore.QRect(50, 40, 46, 13))
self.testlabel.setObjectName("testlabel")
self.NextButton = QtGui.QPushButton(Dialog)
self.NextButton.setGeometry(QtCore.QRect(40, 80, 75, 23))
self.NextButton.setObjectName("NextButton")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.testlabel.setText(QtGui.QApplication.translate("Dialog", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
self.NextButton.setText(QtGui.QApplication.translate("Dialog", "Next", None, QtGui.QApplication.UnicodeUTF8))
主要.py:
from PySide.QtCore import *
from PySide.QtGui import *
import sys
import testTemplate
class MainDialog( QDialog, testTemplate.Ui_Dialog ):
def __init__(self, parent=None):
super(MainDialog, self).__init__(parent)
self.setupUi(self)
self.connect(self.NextButton, SIGNAL("clicked()"), self.changetext)
text_list = ['abc','xyz','bvc']
def changetext(self):
print "print"
app = QApplication(sys.argv)
form = MainDialog()
form.show()
app.exec_()
输出窗口:
问题:
每当我单击Next
按钮时,我希望文本更改为列表中的下一个条目(text_list
在代码中),当列表到达末尾时,它应该关闭窗口。