Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python3和Tkinter:通过OOP以调查形式显示问题和各种答案集_Python_Python 3.x_Class_Oop_Tkinter - Fatal编程技术网

Python3和Tkinter:通过OOP以调查形式显示问题和各种答案集

Python3和Tkinter:通过OOP以调查形式显示问题和各种答案集,python,python-3.x,class,oop,tkinter,Python,Python 3.x,Class,Oop,Tkinter,我正在使用Python3和Tkinter创建一个包含问题和各种可能答案的调查表 以下代码行未显示我的调查问题及其答案集。相反,它们会产生一个错误: 要自定义类的字符串表示形式,可以重写类的\uuu str\uu方法。它应该返回一个字符串。在您的情况下,您可以: class QuestionSet: def __init__(self, *args, **kwargs): self.question = questionSet def __str__(self):

我正在使用Python3和Tkinter创建一个包含问题和各种可能答案的调查表

以下代码行未显示我的调查问题及其答案集。相反,它们会产生一个错误:


要自定义类的字符串表示形式,可以重写类的
\uuu str\uu
方法。它应该返回一个字符串。在您的情况下,您可以:

class QuestionSet:
    def __init__(self, *args, **kwargs):
        self.question = questionSet

    def __str__(self):
        return self.question[0]

要自定义类的字符串表示形式,可以重写类的
\uuu str\uu
方法。它应该返回一个字符串。在您的情况下,您可以:

class QuestionSet:
    def __init__(self, *args, **kwargs):
        self.question = questionSet

    def __str__(self):
        return self.question[0]

在你的
范围内
你指的是
guestion
,但我想你指的是
self.question
。调用
questionStatement.set(q1)
时,您正在将其设置为
q1
的实例引用,此时它需要一个字符串
RadioButton
的标题是驼峰大小写,没有大写,而且它期望
root
作为第一个参数。在
范围内,您指的是
guestion
,但我想您指的是
self.question
。调用
questionStatement.set(q1)
时,您正在将其设置为
q1
的实例引用,此时它需要一个字符串
RadioButton
的标题为驼峰大小写,未大写,并且它希望
作为第一个参数。