class RehabArm(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.iconbitmap(self, default="nurse.ico")
tk.Tk.wm_title(self, "Rehabilitation Arm")
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
menubar = tk.Menu(container)
filemenu = tk.Menu(menubar, tearoff=0)
filemenu.add_command(label="Save Settings",
command = lambda: popupmsg("Not supported just yet"))
filemenu.add_separator()
filemenu.add_command(label="Exit", command=quit)
menubar.add_cascade(label="File", menu=filemenu)
#logo=tk.Icon(filemenu, file="home.ico")
helpmenu = tk.Menu(menubar, tearoff=0)
helpmenu.add_command(label="Tutorial", command=tutorial)
menubar.add_cascade(label="Help", menu=helpmenu)
tk.Tk.config(self, menu=menubar)
self.frames = {}
#add each page here
for F in (WelcomePage, StartPage, ExitPage, DetailsPage, ExercisePage,
ActivePage, PassivePage, CommentPage, SavePage, PageThree):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew") #sticky north south east west
self.show_frame(WelcomePage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class WelcomePage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
label = tk.Label(self, text="Welcome to Physiotherabot", font= SUPERLARGE_FONT)
label.pack(pady=10, padx=10)
button1 = ttk.Button(self, text="Start",
command=lambda: controller.show_frame(StartPage))
#when using button1.grid,, it not giving any error,,,but keep loading
button1.grid(row=1, column=1) #side=tk.TOP, fill=tk.BOTH, expand=True
button2 = ttk.Button(self, text="Exit",
command=lambda: controller.show_frame(ExitPage))
button2.pack() #side=tk.TOP, fill=tk.BOTH, expand=True
如果使用button1.pack
,它可以顺利运行,我尝试配置行和列,但找不到合适的位置,因为它在运行时会继续加载。
答案 0 :(得分:0)
您无法使用.pack()
和.grid()
在同一容器中对齐小部件(请参阅this answer)。
因此,在WelcomePage
中,您需要选择其中一个来对齐button1
和button2
。