TypeError: must be str or None, not Frame

泄露秘密 提交于 2021-01-29 04:09:33

问题


Using an OOP approach to developing a tkinter program for the first time based on the sentdex tkinter series. I honestly have no idea what the error here means.

The error directs me to:

  File "C:\Users\Ash\Dropbox\Programming\Python\WorldManager PY\WorldManager.py", line 59, in __init__
tk.Tk.__init__(self, *args, **kwargs)
File "C:\Python34\lib\tkinter\__init__.py", line 1867, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
TypeError: must be str or None, not Frame

The code I've used is here

EDIT: While the code says the line is 59, the error is on line 46. I took out a few comments from above the code when I pastebinned it.


回答1:


The problem is here:

class frmWelcome(tk.Frame):
    def __init__(self, *args, **kwargs):
        #initialise tkinter
        tk.Tk.__init__(self, *args, **kwargs)

You are inheriting from tk.Frame yet you are calling tk.Tk.__init__ You need to be calling tk.Frame.__init__



来源:https://stackoverflow.com/questions/36532433/typeerror-must-be-str-or-none-not-frame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!