简体   繁体   English

Tkinter类“必须不是元组” TypeError Python

[英]Tkinter Class “must be str not tuple” TypeError Python

I'm getting a problem with Tkinter for python, I have a class, application(root): root is Tk(), and when I run the class without an __init__ function, it works okay, but crashes after I quit the program. 我在使用Tkinter for python时遇到问题,我有一个类, application(root):根是Tk(),当我在没有__init__函数的情况下运行该类时,它可以正常工作,但是在退出程序后崩溃。 With the __init__ , Tkinter tells me __init__ ,Tkinter告诉我

Traceback (most recent call last):
  File "C:\stuff\Portable Python 3.2.0.1\application.pyw", line 75, in <module>
    class application(root):
  File "C:\Python32\lib\tkinter\__init__.py", line 1674, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TypeError: must be str, not tuple

Which doesn't make sense to me, I never gave it a tuple. 这对我来说没有意义,我从来没有给它一个元组。 I'm sorry if this is a very idiot question, I tried googling it and came up with nothing. 很抱歉,如果这是一个非常愚蠢的问题,我尝试使用Google进行搜索,但一无所获。 Thanks. 谢谢。

root is the base class for application . rootapplication的基类。 You have provided an instance of Tk as the base class, rather than the class itself, ie application(Tk) . 您提供了Tk的实例作为基类,而不是类本身,即application(Tk)

It would help if you could show a simple example of your failing code. 如果您可以显示失败代码的简单示例,则将有所帮助。

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

相关问题 Python MySQL TypeError:必须是str,而不是元组 - Python MySQL TypeError: must be str, not tuple 类型错误:参数 1 必须是 str,而不是元组 - TypeError: argument 1 must be str, not tuple TypeError:元组索引必须是整数,而不是str Python / django - TypeError: tuple indices must be integers, not str Python/django Python3 类型错误:“值”必须是 str 或字节的实例,而不是元组 - Python3 TypeError: 'value' must be an instance of str or bytes, not a tuple Python TypeError: bind(): AF_.NET 地址必须是元组,而不是 str - Python TypeError: bind(): AF_INET address must be tuple, not str TypeError:元组索引必须是整数或切片,而不是str Python情绪鸣叫 - TypeError: tuple indices must be integers or slices, not str Python sentiment tweet Python xlsxwriter TypeError:元组索引必须是整数,而不是str - Python xlsxwriter TypeError: tuple indices must be integers, not str Python“ TypeError:getsockaddrarg:AF_INET地址必须为元组,而不是str” - Python “TypeError: getsockaddrarg: AF_INET address must be tuple, not str” 类型错误:元组索引必须是整数或切片,而不是 str postgres/python - TypeError: tuple indices must be integers or slices, not str postgres/python TypeError:元组索引必须是整数,而不是 str - TypeError: tuple indices must be integers, not str
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM