0
我有一個GUI頁面,填充了具有唯一名稱的所需數量的lineedit框。我想稍後使用該名稱將文本分配給相應的lineedit框。下面是代碼:動態GUI頁面屬性錯誤
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_LoadsForm3_1(object):
def setupUi(self, LoadsForm3_1):
LoadsForm3_1.setObjectName(_fromUtf8("LoadsForm3_1"))
LoadsForm3_1.resize(500, 500)
self.scrollArea = QtGui.QScrollArea(LoadsForm3_1)
self.scrollArea.setGeometry(QtCore.QRect(20, 180, 450, 250))
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
self.scrollAreaWidgetContents = QtGui.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -293, 250, 500))
self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
self.gridLayout = QtGui.QGridLayout(self.scrollAreaWidgetContents)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
for i in range (0,10):
lE="lE0"+str(i)+"_P01"+"E0"+str(i)
self.lE =QtGui.QLineEdit(self.scrollAreaWidgetContents)
self.lE.setObjectName(_fromUtf8(lE))
self.gridLayout.addWidget(self.lE, i, 1, 1, 1)
self.scrollArea.setWidget(self.scrollAreaWidgetContent
self.lE01_P01E01.setText("xyz")
if __name__ == "__main__":
import sys app =QtGui.QApplication(sys.argv)
LoadsForm3_1 = QtGui.QDialog()
ui= Ui_LoadsForm3_1()
ui.setupUi(LoadsForm3_1)
LoadsForm3_1.show()
sys.exit(app.exec_())
但在執行它syas:AttributeError的: 'Ui_LoadsForm3_1' 對象有沒有屬性 'lE01_P01E01'。我是Pyqt4的新手,我使用python 2.7。任何幫助表示讚賞。謝謝!!!