【发布时间】:2017-03-28 00:12:10
【问题描述】:
我在一个表单上有三个按钮,例如,当我单击 5% 按钮时,它会打印 5%。但由于某种原因,所有按钮都打印了 60%。
我真的不明白为什么?
我的代码如下。
class ThirdWindow(QWidget, Ui_Form3):
def __init__(self):
super(ThirdWindow, self).__init__()
self.dbu = DatabaseHandling.DatabaseUtility()
self.msl = None
# Show UI on screen + resize window
self.setupUi(self)
self.picIndicator.setPixmap(QPixmap("M:\QtProjects\\Resources\\138691.png"))
self.setFixedSize(350, 480)
# Define what should happen on button click
self.btnQuit.clicked.connect(lambda: self.close())
self.btnSixtyPercent.clicked.connect(lambda: self.check_clicked())
self.btnTenPercent.clicked.connect(lambda: self.check_clicked())
self.btnFivePercent.clicked.connect(lambda: self.check_clicked())
# TODO: Create a window that ask's for the spot it's specific color
'''def indication(self):
d = DialogOne()
d.exec_()'''
def check_clicked(self):
if self.btnSixtyPercent.text() == "60":
print("60%")
elif self.btnFivePercent.text() == "5":
print("5%")
elif self.btnTenPercent.text() == "10":
print("10%")
【问题讨论】: