Анкета tkinter содержит предупреждения

import tkinter as tk
from tkinter import Frame, Button
LARGE_FONT= ("Venom Rockets", 12)

def confirm():
    confirm = "Confirmed" + str(var.get())
    label.config(text = selection)

class config_panel(tk.Tk):

    def __init__(self, *args, **kwargs):

        tk.Tk.__init__(self, *args, **kwargs)
        container = tk.Frame(self)

        container.pack(side="top", fill="both", expand = True)

        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = ()

        for F in (MenuPage, Page1, Page2):
            frame = F(container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky=W)

        self.show_frame(MenuPage)

    def show_frame(self, cont):
        frame = self.frames[cont]
        frame.tkraise()

class MenuPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init(self, parent)
        label = tk.Label(self, text="Configuration Menu", font=LARGE_FONT)
        label.pack(pady=10, padx=10)

        button = tk.Button(self, text="Abort", fg="red", command=quit)
        button.pack()
        button1 = tk.Button(self, text="Start Configuration",
                            command=lambda: controller.show_frame(Page2))

class Page1(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Configuration Page 1", font=LARGE_FONT)
        label.pack(pady=10,padx=10)
        labl1 = tk.Label(self, text="Please confirm launch location", front=LARGE_FONT)
        label1.pack(pady=10,padx=10)
        R1 = Radiobutton(root, text="LC39A.",
                         command=sel)
        R1.pack(anchor=W)
        R2 = Radiobutton(root, text="LC39B.",
                         command=sel)
        R2.pack(anchor=W)
        R3 = Radiobutton(root, text="LC49.",
                         command=sel)
        R3.pack(anchor=W)
        R4 = Radiobutton(root, text="LC13.",
                         command=sel)
        R4.pack(anchor=W)
        R5 = Radiobutton(root, text="LC37B.",
                         command=sel)
        R5.pack(anchor=W)
        R6 = Radiobutton(root, text="LC40.",
                         command=sel)
        R6.pack(anchor=W)
        R7 = Radiobutton(root, text="LC41.",
                         command=sel)
        R7.pack(anchor=W)
        R8 = Radiobutton(root, text="LC47.",
                         command=sel)
        R8.pack(anchor=W)
        Nextbtn = tk.Button(self, text="Confirm, Next.",
                            command=lambda: controller.show_frame(Page2))
        Nextbtn.pack()

class Page2(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Configuration Page 2", front=LARGE_FONT)
        label.pack(pady=10,padx=10)
        label1 = tk.Label(self, text="Please confirm rocket direction", front=LARGE_FONT)
        label1.pack(pady=10,padx=10)
        R1 = Raidobutton(root, text="North.",
                         command=sel)
        R1.pack(anchor=W)
        R2 = Radiobutton(root, text="East.",
                         command=sel)
        R2.pack(anchor=W)
        R3 = Radiobutton(root, text="South.",
                         command=sel)
        R3.pack(anchor=W)
        R4 = Radiobutton(root, text="West.",
                         command=sel)
        R4.pack(anchor=W)
        Nextbtn = tk.Button(self, text="Confirm, Next.",
                            command=lambda: controller.show_frame(MenuPage))
        Nextbtn.pack()

app = config_panel()
app.mainloop()

это весь мой код, но я получаю эту ошибку:

Traceback (most recent call last):
  File "C:/Users/Samuel Berlet/Desktop/rfnirfi.py", line 105, in <module>
    app = config_panel()
  File "C:/Users/Samuel Berlet/Desktop/rfnirfi.py", line 24, in __init__
    frame = F(container, self)
  File "C:/Users/Samuel Berlet/Desktop/rfnirfi.py", line 37, in __init__
    tk.Frame.__init(self, parent)
AttributeError: type object 'Frame' has no attribute '_MenuPage__init' 

Когда я пытаюсь запустить его. Я хочу сделать своего рода анкету. Как будто будет страница меню с Configure или Abort Abort отключит всю Вещи. Configure откроет другое окно, в котором будет set1 вопросов (место запуска), затем после этого set 2 и т. Д. Как мне сделать это, пожалуйста, может кто-то Помоги мне с кодом.

1 ответ

В последней строке трассировки поставьте двойное подчеркивание (__) после, как и раньше __init__, В вашем коде есть другие проблемы.

Другие вопросы по тегам