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
15-05-2022 | |
perfect, thanks |