Hello, I am getting an error when calling function from apps_5 modul into main. I need those 3 modules, becouse a lot of code will be inside. Any help would be appreciatted.
An error:
An error:
Error:Traceback (most recent call last):
File "/home/pi/Desktop/Qt4/Project/01/Test_Class/apps_5.py", line 8, in print_situation
self.checkBox = QtGui.QCheckBox(self)
TypeError: arguments did not match any overloaded call:
QCheckBox(QWidget parent=None): argument 1 has unexpected type 'bool'
QCheckBox(QString, QWidget parent=None): argument 1 has unexpected type 'bool'main:# python 2.7.9 from PyQt4 import QtCore, QtGui import gui_5 from apps_5 import print_situation import sys if __name__ == "__main__": app = QtGui.QApplication(sys.argv) gui_master = gui_5.QtGui.QWidget() master = gui_5.Ui_Form() master.setupUi(gui_master) master.checkBox.clicked.connect(print_situation) gui_master.show() sys.exit(app.exec_())gui modul:
from PyQt4 import QtCore, QtGui
import apps_5
#from apps_2 import my_app
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_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(400, 300)
self.checkBox = QtGui.QCheckBox(Form)
self.checkBox.setGeometry(QtCore.QRect(200, 150, 100, 26))
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.checkBox.setText(_translate("Form", "CheckBox", None))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())apps_5 modul: # python 2.7.9 from PyQt4 import QtCore, QtGui import gui_5 def print_situation(self): self.checkBox = QtGui.QCheckBox(self) if self.checkBox.checkState() == QtCore.Qt.Checked: print "Checked" else: print "Unchecked"
