[英]how can I disable a push button after it was clicked once?
I'v created a GUI with a button called "start". 我用一个名为“开始”的按钮创建了一个GUI。
After it was clicked once, I need this button to be disabled. 单击一次后,我需要禁用此按钮。
the button definition: 按钮定义:
QtCore.QObject.connect(self.start, QtCore.SIGNAL(_fromUtf8("clicked()")), self.constant)
You have to connect the clicked signal to invoke the setDisabled method, and to do it in a few lines you can use functools.partial. 您必须连接单击的信号才能调用setDisabled方法,并且只需几行即可使用functools.partial。
from functools import partial
# ...
wrapper = partial(self.start.setDisabled, True)
self.start.clicked.connect(wrapper)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.