简体   繁体   English

PyQt4复选框不响应-OSX

[英]PyQt4 Checkbox not responding - OSX

I am getting a really weird issue here. 我在这里遇到一个很奇怪的问题。 A simple python app with a checkbox once I click on the checkbox (cb) it doesn't change its state and it doesn't change the GUI visualization. 一个带有复选框的简单python应用程序,一旦我单击复选框(cb),它就不会更改其状态,也不会更改GUI可视化。

Any ideas ? 有任何想法吗 ?

Here is my python snippet 这是我的python代码段

a = QApplication(sys.argv)
w = QWidget()
cb = QCheckBox("Auto-Launch", w)
cb.move(220, 110)
cb.stateChanged.connect(handleLaunch)

I found out what was causing this. 我发现是什么原因造成的。

I had a QProgressBar, which was close to the checkbox and though visually it didn't seem that way. 我有一个QProgressBar,它靠近复选框,尽管在外观上似乎不是那样。 In reality was covering the checkbox, so the click wasn't reaching the checkbox at all. 实际上是覆盖该复选框,因此单击根本没有到达该复选框。

here is the full code with the problem. 这是有问题的完整代码。

from PyQt4.QtGui import *
import sys

a = QApplication(sys.argv)
w = QWidget()
w.resize(320, 240)

cb = QCheckBox("Auto-Launch", w)
cb.move(220, 110)

download_bar = QProgressBar(w)
download_bar.resize(300,50)
download_bar.setValue(0)
download_bar.move(10,110)

w.show()
sys.exit(a.exec_())

and here is the full solution 这是完整的解决方案

from PyQt4.QtGui import *
import sys

a = QApplication(sys.argv)
w = QWidget()
w.resize(320, 240)

download_bar = QProgressBar(w)
download_bar.resize(300,50)
download_bar.setValue(0)
download_bar.move(10,110)

cb = QCheckBox("Auto-Launch", w)
cb.move(220, 110)

w.show()
sys.exit(a.exec_())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM