So I have the following, which works perfectly:
import tkinter as tk
class App(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 (LoginPage, ProjPage):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, rowspan=12, columnspan=6, sticky="nsew")
self.show_frame(LoginPage)
def show_frame(self, c):
frame = self.frames[c]
frame.tkraise()
class LoginPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
Btn = tk.Button(self, text="Sign In", command=lambda: controller.show_frame(ProjPage))
But I want that last button command to be in a separate function, so I can do some evaluations first:
Btn = tk.Button(self, text="Sign In", command=self.signIn)
def signIn(self):
# do some stuff here
self.controller.show_frame(ProjPage)
This doesn't work; regardless if I try to pass the controller, or use a lambda, nothing seems to work >.<
What am I not getting?
You don't seem to initialize controller in self. Put it there in __init__ of LoginPage, like so:
self.controller = controller
my program has a page(main page) that has 5 radio button in it and a button "ok",and I have 5 other Frame. I want my program to go to these frames after clicking the "ok" ( based on the chosen radio button).
when the "ok" is clicked it will call a lambda and get the value of chosen radiobutton and based on this valuefind the string (veg) which represent the name of the page.
here is the code:
import tkinter as tk
from tkinter import ttk
from win32print import StartPage
class KBSapp(tk.Tk):
def init(self, *args, **kwargs):
tk.Tk.init(self, *args, **kwargs)
tk.Tk.iconbitmap(self,default="icon.ico")
tk.Tk.wm_title(self, "Diseases and pests of vegetable crops")
container = tk.Frame(self, width=200, height=200, bg='black')
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 (StartPage,carrot,celery, potato, wheat, bean):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise( )
class StartPage(tk.Frame):
def init(self, parent, controller):
tk.Frame.init(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack()
button2 = ttk.Button(self, command=lambda : okclick(v) ,text='OK', width=25)
button2.pack( )
v = tk.IntVar( )
self.option1 = ttk.Radiobutton(self, text="Carrot", variable=v, value=1);self.option1.pack( )
self.option2 = ttk.Radiobutton(self, text="Celery", variable=v, value=2);self.option2.pack( )
self.option3 = ttk.Radiobutton(self, text="potato", variable=v, value=3);self.option3.pack( )
self.option4 = ttk.Radiobutton(self, text="wheat", variable=v, value=4);self.option4.pack( )
self.option5 = ttk.Radiobutton(self, text="bean", variable=v, value=5);self.option5.pack( )
v.set(1) # initializing the choice
def okclick(v):
global veg
input1=v.get( )
if input1==1:
veg="carrot"
if input1==2:
veg='celery'
if input1==3:
veg='potato'
if input1==4:
veg='wheat'
if input1==5:
veg='bean'
print(veg)
class carrot(tk.Frame):
def init(self, parent, controller):
tk.Frame.init(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button3 = ttk.Button(self, command=lambda : controller.show_frame(celery) , text='celery', width=25)
button3.pack( )
class celery(tk.Frame):
def init(self, parent, controller):
tk.Frame.init(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(potato) , text='potato', width=25)
button4.pack( )
class potato(tk.Frame):
def init(self, parent, controller):
tk.Frame.init(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(wheat) , text='wheat', width=25)
button4.pack( )
class wheat(tk.Frame):
def init(self, parent, controller):
tk.Frame.init(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(bean) , text='bean', width=25)
button4.pack( )
class bean(tk.Frame):
def init(self, parent, controller):
tk.Frame.init(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(StartPage) , text='StartPage', width=25)
button4.pack( )
app = KBSapp( )
app.mainloop( )
Related
I had a problem with passing a variable from one page to the other, its works now, but if I want to use it on a label, it writes PA_VAR0. I read that ".get()" should be used in that case, but it still doesn't work that way. (with .get() it don't even passes the variable). I tried to set a new variable with tk.StringVar() function, but it still didn't work
import tkinter as tk
from tkinter import ttk
class example(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.shared_data = {
"variable": tk.StringVar()
}
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 (page1, page2):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(page1)
def get_page(self, page_class):
return self.frames[page_class]
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class page1(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, text="first page")
label.grid(row=0, column=4, padx=10, pady=10)
button1 = ttk.Button(self, text="turn page",
command=lambda: self.pageturn())
button1.grid(row=3, column=1, padx=10, pady=10)
def pageturn(self):
self.controller.shared_data["variable"] = 'string i wanna pass'
print("variable set here: ", self.controller.shared_data["variable"])
self.controller.show_frame(page2)
class page2(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, text=self.controller.shared_data["variable"])
label.grid(row=0, column=4, padx=10, pady=10)
label = ttk.Label(self, text=self.controller.shared_data["variable"].get())
label.grid(row=1, column=4, padx=10, pady=10)
button3 = ttk.Button(self, text=self.controller.shared_data["variable"],
command=lambda: print(self.controller.shared_data["variable"]))
button3.grid(row=8, column=10, padx=10, pady=10)
button2 = ttk.Button(self, text="if fuction sees variable",
command=lambda: self.ifok())
button2.grid(row=9, column=10, padx=10, pady=10)
def ifok(self):
if self.controller.shared_data["variable"] == 'string i wanna pass':
print("ok")
app = example()
app.mainloop()
You overwrite self.controller.shared_data["variable"] by a string inside pageturn():
self.controller.shared_data["variable"] = 'string i wanna pass'
You should use .set() instead:
self.controller.shared_data["variable"].set('string i wanna pass')
Full updated code:
import tkinter as tk
from tkinter import ttk
class example(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.shared_data = {
"variable": tk.StringVar()
}
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 (page1, page2):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(page1)
def get_page(self, page_class):
return self.frames[page_class]
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class page1(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, text="first page")
label.grid(row=0, column=4, padx=10, pady=10)
button1 = ttk.Button(self, text="turn page",
command=lambda: self.pageturn())
button1.grid(row=3, column=1, padx=10, pady=10)
def pageturn(self):
self.controller.shared_data["variable"].set('string i wanna pass') ### changed = to .set()
print("variable set here: ", self.controller.shared_data["variable"].get()) ### called .get()
self.controller.show_frame(page2)
class page2(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, textvariable=self.controller.shared_data["variable"]) ### changed text to textvariable
label.grid(row=0, column=4, padx=10, pady=10)
label = ttk.Label(self, text=self.controller.shared_data["variable"].get())
label.grid(row=1, column=4, padx=10, pady=10)
button3 = ttk.Button(self, textvariable=self.controller.shared_data["variable"], ### changed text to textvariable
command=lambda: print(self.controller.shared_data["variable"].get()))
button3.grid(row=8, column=10, padx=10, pady=10)
button2 = ttk.Button(self, text="if fuction sees variable",
command=lambda: self.ifok())
button2.grid(row=9, column=10, padx=10, pady=10)
def ifok(self):
if self.controller.shared_data["variable"].get() == 'string i wanna pass': ### called .get()
print("ok")
app = example()
app.mainloop()
I have two frames to switch around. In each frame, there is an Entry box. How do I set my input in the first Entry box in the first frame as the default text for the second Entry box in the second frame?
from tkinter import *
class Root(Tk):
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
container = 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 (PageOne, PageTwo):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("PageOne")
def show_frame(self, page_name):
frame = self.frames[page_name]
frame.tkraise()
def quit(self):
self.destroy()
text = ''
class PageOne(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
global text
entry_box_1 = Entry(self, width=40)
entry_box_1.pack()
text = entry_box_1.get()
quit_button = Button(self, text="Quit Program",
command=lambda: controller.quit())
next_button = Button(self, text="Next",
command=lambda: controller.show_frame('PageTwo'))
next_button.pack()
quit_button.pack()
class PageTwo(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
entry_box_2 = Entry(self, width=40)
entry_box_2.insert(END, text)
entry_box_2.pack()
quit_button = Button(self, text="Quit Program",
command=lambda: controller.quit())
back_button = Button(self, text="Back",
command=lambda: controller.show_frame("PageOne"))
back_button.pack()
quit_button.pack()
if __name__ == "__main__":
root = Root()
root.mainloop()
My second Entry box keeps being blank when I switch to the second frame.
You are initializing the PageTwo frame when text variable is an empty string and while you are switching to this frame you are not inserting any value to entry_box_2.
I suggest you to invoke the insert method every time you are switching to the PageTwo frame. You can do this by creating a new switching method that can be similar to show_frame_with_default_text method in the following code.
from tkinter import *
class Root(Tk):
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
container = 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 (PageOne, PageTwo):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("PageOne")
def show_frame(self, page_name):
frame = self.frames[page_name]
frame.tkraise()
def show_frame_with_default_text(self, page_name, text):
frame = self.frames[page_name]
frame.entry_box.delete(0, END)
frame.entry_box.insert(0, text)
frame.tkraise()
def quit(self):
self.destroy()
class PageOne(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
entry_box_1 = Entry(self, width=40)
entry_box_1.pack()
quit_button = Button(self, text="Quit Program",
command=lambda: controller.quit())
next_button = Button(self, text="Next",
command=lambda: controller.show_frame_with_default_text('PageTwo', entry_box_1.get()))
next_button.pack()
quit_button.pack()
class PageTwo(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.controller = controller
self.entry_box = Entry(self, width=40)
self.entry_box.pack()
quit_button = Button(self, text="Quit Program",
command=lambda: controller.quit())
back_button = Button(self, text="Back",
command=lambda: controller.show_frame("PageOne"))
back_button.pack()
quit_button.pack()
if __name__ == "__main__":
root = Root()
root.mainloop()
I am trying to add a variable inside of class, and also grid it with the e1.grid() command. I can create the variable inside of the class but for some reason I can't grid the variable and I can't grid text either. Is there any way to solve this problem?
import tkinter as tk
from tkinter import font as tkfont
from tkinter import Entry
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.title_font = tkfont.Font(family='Helvetica', size=18,
weight="bold", slant="italic")
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 (StartPage, PageOne):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("StartPage")
def show_frame(self, page_name):
'''Show a frame for the given page name'''
frame = self.frames[page_name]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is the start page",
font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
button1 = tk.Button(self, text="Go to Page One",
command=lambda:
controller.show_frame("PageOne"))
button1.pack()
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is page 1",
font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="Go to the start page",
command=lambda:
controller.show_frame("StartPage"))
button.pack()
e1 = Entry(self)
e1.grid(row=0, column=1)
if __name__ == "__main__":
app = SampleApp()
app.mainloop()
you can't use pack with grid together.
'''
e1 = Entry(self).pack()
#e1.grid(row=0, column=1)
'''
so...
import tkinter as tk
from tkinter import font as tkfont
from tkinter import Entry
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.title_font = tkfont.Font(family='Helvetica', size=18,
weight="bold", slant="italic")
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 (StartPage, PageOne):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("StartPage")
def show_frame(self, page_name):
'''Show a frame for the given page name'''
frame = self.frames[page_name]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is the start page", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
button1 = tk.Button(self, text="Go to Page One",command=lambda: controller.show_frame("PageOne"))
button1.pack()
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is page 1", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="Go to the start page",command=lambda: controller.show_frame("StartPage"))
button.pack()
e1 = Entry(self).pack()
#e1.grid(row=0, column=1)
if __name__ == "__main__":
app = SampleApp()
app.mainloop()
update
if you want use grid method you must grid for all widgets in the relative page
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is page 1", font=controller.title_font)
label.grid(row=0, column=0)
button = tk.Button(self, text="Go to the start page",command=lambda: controller.show_frame("StartPage"))
button.grid(row=0, column=1)
e1 = Entry(self)
e1.grid(row=1, column=0)
I'm designing a login screen for my chat application. As I don't have much information about switching frames, I'm looking at the code here and edit for my project accordingly. For now, I want the "Page 2" to be shown when the credentials are entered correctly. However, when I enter the nickname and password correctly, nickname form remains in the second screen and it looks messed up like in the screenshoot I uploaded. Screenshot
How can I solve this problem? The code is below:
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.title_font = tkfont.Font(family='Helvetica', size=18, weight="bold", slant="italic")
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 (StartPage, PageOne, PageTwo):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
F.grid_propagate(self)
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("StartPage")
def show_frame(self, page_name):
frame = self.frames[page_name]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent, width=500, height=500)
self.controller = controller
db = MySQLdb.connect(host="localhost", user="root", passwd="", db="members")
cursor = db.cursor()
label = tk.Label(self, text="Nickname:")
label.place(x=140, y=150)
user_id = tk.Entry()
user_id.place(x=210, y=150)
label_2 = tk.Label(self, text="Password:")
label_2.place(x=140, y=200)
password = tk.Entry(self, show="*")
password.place(x=210, y=200)
def auth_login(event=None):
id = user_id.get()
pswd = password.get()
cursor.execute(
"SELECT nickname, password FROM chatmembers WHERE nickname='{}' AND password='{}' ".format(id, pswd))
if cursor.fetchone():
controller.show_frame("PageTwo")
else:
messagebox.showerror("Wrong credentials", "Either nickname or password is wrong. Please try again.")
login_button = tk.Button(self, text="Log In", command=auth_login, height=2, width=20)
login_button.place(x=195, y=250)
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent, width=500, height=500)
self.controller = controller
label = tk.Label(self, text="This is page 1", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="Go to the start page",
command=lambda: controller.show_frame("StartPage"))
button.place(x=100, y=200)
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="This is page 2", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
button = tk.Button(self, text="Go to the start page",
command=lambda: controller.show_frame("StartPage"))
button.pack()
if __name__ == "__main__":
app = SampleApp()
app.mainloop()
my program has a page(main page) that has 5 radio button in it and a button "ok",and I have 5 other Frame. I want my program to go to these frames after clicking the "ok" ( based on the chosen radio button).
when the "ok" is clicked it will call a lambda and get the value of chosen radiobutton and based on this value put the correct string (veg) which represent the name of the page we want to go to. I don't know where to call this:
controller.show_frame(veg)
if i put : controller.show_frame(veg) in the okclick function I receive this error:
Exception in Tkinter callback Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\tkinter_init_.py", line 1699, in call return self.func(*args) File "C:/Users/AI/PycharmProjects/KBS/alaki.py", line 37, in button2 = ttk.Button(self, command=lambda : okclick(v) ,text='OK', width=25) File "C:/Users/AI/PycharmProjects/KBS/alaki.py", line 65, in okclick controller.show_frame(veg) NameError: name 'controller' is not defined
here is the code:
import tkinter as tk
from tkinter import ttk
from win32print import StartPage
class KBSapp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.iconbitmap(self,default="icon.ico")
tk.Tk.wm_title(self, "Diseases and pests of vegetable crops")
container = tk.Frame(self, width=200, height=200, bg='black')
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 (StartPage,carrot,celery, potato, wheat, bean):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise( )
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack()
button2 = ttk.Button(self, command=lambda : okclick(v) ,text='OK', width=25)
button2.pack( )
v = tk.IntVar( )
self.option1 = ttk.Radiobutton(self, text="Carrot", variable=v, value=1);self.option1.pack( )
self.option2 = ttk.Radiobutton(self, text="Celery", variable=v, value=2);self.option2.pack( )
self.option3 = ttk.Radiobutton(self, text="potato", variable=v, value=3);self.option3.pack( )
self.option4 = ttk.Radiobutton(self, text="wheat", variable=v, value=4);self.option4.pack( )
self.option5 = ttk.Radiobutton(self, text="bean", variable=v, value=5);self.option5.pack( )
v.set(1) # initializing the choice
def okclick(v):
global veg
input1=v.get( )
if input1==1:
veg="carrot"
if input1==2:
veg='celery'
if input1==3:
veg='potato'
if input1==4:
veg='wheat'
if input1==5:
veg='bean'
print(veg)
class carrot(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button3 = ttk.Button(self, command=lambda : controller.show_frame(celery) , text='celery', width=25)
button3.pack( )
class celery(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(potato) , text='potato', width=25)
button4.pack( )
class potato(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(wheat) , text='wheat', width=25)
button4.pack( )
class wheat(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(bean) , text='bean', width=25)
button4.pack( )
class bean(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, width=0, height=20)
label.pack( )
button4 = ttk.Button(self, command=lambda : controller.show_frame(StartPage) , text='StartPage', width=25)
button4.pack( )
app = KBSapp( )
app.mainloop( )