【问题标题】:AttributeError: module 'tkinter' has no attribute 'Tk__init__'AttributeError:模块“tkinter”没有属性“Tk__init__”
【发布时间】:2020-08-30 12:34:23
【问题描述】:
    def __init__(self, *args, **kwargs):
    tk.Tk__init__(self, *args, **kwargs)
    container=tk.Frame(self)
    container.pack(side='top',fill='both',expand=True)
    continer.grid_rowconfigure(0,weight=1)
    container.grid_columnconfigure(0,weight=1)

请帮帮我,我在 https://www.youtube.com/watch?v=A0gaXfM1UN0&list=PLQVvvaa0QuDclKx-QpC9wntnURXVJqLyk&index=2 上观看它,但它对我不起作用

【问题讨论】:

  • 这是tk.Tk.__init__,而不是tk.Tk__init__

标签: python tkinter


【解决方案1】:

只需使用super() 而不是Tk.__init__()

from tkinter import Tk

class CustomGui(Tk):
    def __init__(self):
        super(CustomGui,self).__init__()

【讨论】:

    猜你喜欢
    • 2018-11-18
    • 2017-03-21
    • 1970-01-01
    • 1970-01-01
    • 2018-04-14
    • 2019-02-18
    • 1970-01-01
    • 2020-01-01
    • 1970-01-01
    相关资源
    最近更新 更多