state Option of Notebook ( tabs )

Tkinter Notebook

ttk Notebook state option

Tkinter Notebook to create tabs and managing options to add image underline state with click events


We can manage the state option of the Notebook through buttons. Full Code is here.

state option

normal : this is the default value with all functionality.
disabled : Not selectable but visible
hidden : Not visible
import tkinter  as tk 
from tkinter import *
from tkinter import ttk
my_w = tk.Tk()
my_w.geometry("400x200")  
my_tabs = ttk.Notebook(my_w) # declaring 

tab0 = ttk.Frame(my_tabs)
tab1 = ttk.Frame(my_tabs)
tab2 = ttk.Frame(my_tabs)

my_tabs.add(tab0, text ='Tab-0') # adding tab
my_tabs.add(tab1, text ='Tab-1') # adding tab 
my_tabs.add(tab2, text ='Tab-2') # adding tab 
my_tabs.pack(expand = 1, fill ="both")

font1=('times',22,'normal') # font size 
l1=tk.Label(tab0,text='I am tab-0',bg='yellow',font=font1)
l1.place(relx=0.3,rely=0.2) # using place layout

l2=tk.Label(tab1,text='I am tab-1',bg='yellow',font=font1)
l2.place(relx=0.3,rely=0.2)

l3=tk.Label(tab2,text='I am tab-2',bg='yellow',font=font1)
l3.place(relx=0.3,rely=0.2)

#place three buttons in parent window to manage the state option
b1=tk.Button(my_w,text='Disabled',
     command=lambda:my_tabs.tab(tab1,state='disabled'))
b1.pack(side=LEFT) 
b2=tk.Button(my_w,text='normal',
     command=lambda:my_tabs.tab(tab1,state='normal'))
b2.pack(side=LEFT) 
b3=tk.Button(my_w,text='hidden',
     command=lambda:my_tabs.tab(tab1,state='hidden'))
b3.pack(side=LEFT) 

my_w.mainloop()  # Keep the window open

Notebook

hide() forget() and select() Methods Tab Option sticky underline image
On Tab change event to display Tab Number

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer