擅长:python、mysql、java
<p>试试这个</p>
<pre><code>while i <= int(seqNum):
#create each widget
createShotBtn = "ShotBtn"+str(i)
self.createShotBtn = QtGui.QPushButton("Create Shot %s!" %str(self.shotNumberLst[i-1]))
labelName = "labName"+str(i)
self.labelName = QtGui.QLabel(self)
self.labelName.setText("Enter Name Of Shot %s!" %str(self.shotNumberLst[i-1]))
shotName = "shtName"+str(i)
self.shotName = QtGui.QLineEdit(self)
#add widget to layout
self.grid.addWidget(self.labelName, 11+shotjump,0)
self.grid.addWidget(self.shotName,11+shotjump,1)
self.grid.addWidget(self.createShotBtn, 11+shotjump,2)
#Press button that makes magic happen
self.createShotBtn.clicked.connect(self.printText)
i += 1
def printText(self):
print(self.shotName.text())
</code></pre>
<p>当你按下同一行的按钮时,这将打印文本。在</p>