Τελικά βρήκα ακριβώς αυτό που ήθελα μετά απο πολύ ψάξιμο ο κώδικας είναι παρακάτω με αρκετες αλλαγές απο τον αρχικό:
# -*- coding: utf8 -*-
import Tkinter as tk
from Tkinter import *
import tkMessageBox
TITLE_FONT = ("Helvetica", 50, "bold")
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
# the container is where we'll stack a bunch of frames
# on top of each other, then the one we want visible
# will be raised above the others
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):
frame = F(container, self)
self.frames[F] = frame
# put all of the pages in the same location;
# the one on the top of the stacking order
# will be the one that is visible.
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, c):
'''Show a frame for the given class'''
frame = self.frames[c]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
# -- Do not change. You may experience problems with the design file. -- #
textBox2=tk.Entry(self,font = '{MS Sans Serif} 11',show='*')
textBox2.place(relx=0.57, rely=0.40, relwidth=0.20, relheight=0.20)
# -- Do not change. You may experience problems with the design file. -- #
textBox1=tk.Entry(self,font = '{MS Sans Serif} 11')
textBox1.place(relx=0.57, rely=0.07, relwidth=0.20, relheight=0.20)
# -- Do not change. You may experience problems with the design file. -- #
label2=tk.Label(self,text='Κωδικος Χρήστη')
label2.place(relx=0.02, rely=0.40, relwidth=0.41, relheight=0.09)
# -- Do not change. You may experience problems with the design file. -- #
label1=tk.Label(self,text='Όνομα Χρήστη')
label1.place(relx=0.02, rely=0.07, relwidth=0.41, relheight=0.09)
# -- Do not change. You may experience problems with the design file. -- #
button1=tk.Button(self,text='Είσοδος', command=lambda: controller.show_frame(PageOne))
button1.pack(side=BOTTOM)
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="This is page 1", font=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()