Apr-19-2020, 11:37 AM
Hi, I'm trying to use multitab frame in my script. My plan is to create the pages I need in different .py then use this as main page to start my program
This is my first page code:
Thank to whoever could help me
from tkinter import * from Page1 import * from Page2 import * from Page3 import *class App(Tk): def __init__(self,*args,**kwargs): Tk.__init__(self,*args,**kwargs) self.notebook = ttk.Notebook() self.add_tab() self.notebook.grid(row=0) def add_tab(self): tab1 = Instructions(self.notebook) tab2 = Mainframe(self.notebook) tab3 = Test(self.notebook) self.notebook.add(tab,text="p1") self.notebook.add(tab2,text="p2") self.notebook.add(tab3,text="p3") class Page1(Frame): def __init__(self,name,*args,**kwargs): Frame.__init__(self,*args,**kwargs) self.name = name class Page2(Frame): def __init__(self,name,*args,**kwargs): Frame.__init__(self,*args,**kwargs) self.name = name class Page3(Frame): def __init__(self,name,*args,**kwargs): Frame.__init__(self,*args,**kwargs) self.name = name my_app = App() my_app.mainloop()but when I try to make it run all pages appear in different windows and only after I close them finally appear the window with my tab (that are empty). How can I fix this?
This is my first page code:
from openpyxl import * from tkinter import * from datetime import datetime wb = load_workbook('C:\\Users\\MyPC\\Desktop\\\\exc.xlsx') sheet = wb.active datetimeFormat = '%d-%m-%Y' class Page1(Frame): def __init__(self,master,*args,**kwargs): global msg, inv_cnt excel() inv_cnt=1 Frame.__init__(self,master,*args,**kwargs) #label #entry class App(Tk): def __init__(self): global value Tk.__init__(self) self.title("Fake News Survey") self.geometry('400x500') self.resizable(0,0) # create and pack a Mainframe window Mainframe(self).place(x=0,y=0,height=880,width=880) self.mainloop()and my second one
from tkinter import * window=Tk() S = Scrollbar(window) T = Text(window, padx = 10, pady = 10, spacing1 = 10, spacing2 = 1, bd = 2) S.pack(side=RIGHT, fill=Y) T.pack(side=LEFT, expand=True, fill=BOTH) S.config(command=T.yview) T.config(yscrollcommand=S.set, background="LIGHT GRAY") T.tag_configure('big', font=('times', 15, 'bold'), justify='center') T.tag_configure('normal', font=('times', 12)) T.insert(END,'Instructions\n', 'big') quote = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id augue tempor lectus ornare mollis at sed felis.""" T.insert(END, quote, 'normal') T.config(state=DISABLED) window.title('PAGE2') window.geometry("400x500") window.mainloop()Basically I don't know how to format my page to be able to fit in the multitab and how to call it in my main page. Also how could I disable a tab and then able it after the use of a button?
Thank to whoever could help me
