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'
当我尝试运行它时。我想做一份问卷。就像会有一个带有配置或中止的菜单页面 中止将关闭整个事物 配置将打开另一个窗口,其中将设置 1 个问题(启动位置),然后在设置 2 等之后。我该如何做这个请有人帮我写代码。