How to create a 3 tab window on tkinter

Question:

As i state in the title, i’m trying to create a 3 tab window by using tkinter on pythen.
I tried to expand an example of a two tabs window that i’ve found, but i got no luck. What i’ve tried to to so far :

window = Tk()
window.title(board control')
window.geometry('1920x900')


tab_control = ttk.Notebook(        window)
tab2        =         Frame(  tab_control)
tab_control.add(tab2, text= 'Title')
tab3        =         Frame(  tab_control)
tab_control.add(tab3, text= 'Title')
tab4        =         Frame(  tab_control)
tab_control.add(tab4, text= 'Title')
tab_control.pack(expand= 1,  fill= "both")

I’ve added the tab4 and tab4 control lines, but ony two tabs appear. Any suggestions would be welcomed

Asked By: AlexandrosS

||

Answers:

This is how I’m doing this in my app:

#Create the root window
root = tk.Tk()
root.title("My App")
root.geometry("900x800")

#Create Tab control
tabControl = ttk.Notebook(root)

#Create frame for each tab, and add to tab control  
tab1 = ttk.Frame(tabControl); tabControl.add(tab1, text ='Overview')
tab2 = ttk.Frame(tabControl); tabControl.add(tab2, text ='2nd tab')
tab3 = ttk.Frame(tabControl); tabControl.add(tab3, text ='3rd')
tab4 = ttk.Frame(tabControl); tabControl.add(tab4, text ='4th')
tab5 = ttk.Frame(tabControl); tabControl.add(tab5, text ='5th')
tab6 = ttk.Frame(tabControl); tabControl.add(tab6, text ='6th')
tab7 = ttk.Frame(tabControl); tabControl.add(tab7, text ='7th')

#pack the tab control onto the window
tabControl.pack(expand = 1, fill ="both")
Answered By: mrblue6
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.