#from tkinter.scrolledtext import ScrolledText
from tkinter import *
import tkinter as tk
import tkinter.filedialog
from tkinter.filedialog import askopenfilename
Title_font = ("Comic Sans MS",20,"bold")
Sub_font =("Comic Sans MS",15,"bold")
Nor_font = ("Calibri",15)
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,FormPage):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = 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, 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
lb1 = tk.Label(self, text="Filename", font= ('Plantagenet Cherokee',20,'bold'))
lb1.grid(row=3,column=8,sticky = "E")
entry_2 = Entry(self,font=('Arial',12))
entry_2.grid(row=3,column=9)
go_button = tk.Button(self, text="Browse",
command=self.selectfile)
gen_button = tk.Button(self, text="Generate",command =lambda: controller.show_frame("FormPage") )
go_button.grid(row=3,column=20,pady=20,padx=10)
gen_button.grid(row=4,column=9,pady=5)
def selectfile(self):
custName = StringVar(None)
fileName = askopenfilename(parent=self, title='Choose a file', initialdir='C:\\')
custName.set(fileName) #Populate the text field with the selected file
#entry_1 = Entry(self, width ='20', textvariable=custName)
#entry_1.grid(row=0,column= 1)
class FormPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = tk.Label(self, text="Fill The Gap Questions:", font=("Plantagenet Cherokee",30,"bold"))
label.grid(row=4,column=2,pady=10)
# button = tk.Button(self, text="SUBMIT")
#button.grid(row=2,column=1,sticky=E,pady=5)
b2=tk.Button(self,text='BACK',command=lambda: controller.show_frame("StartPage"))
b2.grid(row=0,column=0,pady=5)
if __name__ == "__main__":
app = SampleApp()
app.geometry('400x400')
app.mainloop()