-1
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

If using button1.pack, it can run smoothly, I try to configure row and column, but cannot find the suitable place because it keep loading when I run it.

Taku
  • 31,927
  • 11
  • 74
  • 85
Kas
  • 3
  • 2

1 Answers1

0

You cannot use .pack() and .grid() to align widgets in the same container (see this answer).

So in WelcomePage you need to choose one of them to align button1 and button2.

Community
  • 1
  • 1
Josselin
  • 2,593
  • 2
  • 22
  • 35
  • thank you soo much,,, i always forgot to change the label.pack to label.grid... now i can use grid.. but i have one more problem,, i cannot include image ,, can you help me – Kas Apr 14 '17 at 10:01
  • logo = ImageTk.PhotoImage(file='home.ico') button.config(image=logo, compound='left') – Kas Apr 14 '17 at 10:01
  • i try the above coding,, there is no error,,but the image wont show – Kas Apr 14 '17 at 10:02
  • You have to keep a reference to your button image, for it to be properly displayed (http://effbot.org/tkinterbook/photoimage.htm). You can do this by adding `button.logo = logo` after `button.config(...)` – Josselin Apr 14 '17 at 10:34
  • Finally, please accept the answer if it fixed your problem :) http://stackoverflow.com/help/accepted-answer – Josselin Apr 14 '17 at 10:36