Python Forum
What to do to avoid error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What to do to avoid error
#2
(Jan-29-2017, 11:08 AM)California Wrote:
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'
# 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"

Sounds like print_situation() is being called with different parameters than you expect it is.  For example, what do you think "self" means here?  Because whatever you think it is, it's apparently a True/False.

My suggestion would be to either 1) change the function to have *args and then print them out so you see what it's actually getting called with, or 2) look up the docs for what button.click.connect does.
Reply


Messages In This Thread
What to do to avoid error - by California - Jan-29-2017, 11:08 AM
RE: What to do to avoid error - by nilamo - Feb-03-2017, 05:47 PM
RE: What to do to avoid error - by California - Feb-03-2017, 09:07 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020