Last Updated : 12 Jul, 2025
Python offers a range of GUI frameworks that can be used to develop GUI based applications in Python. The most widely used Python interface is Tk interface or
tkinter( as renamed in Python 3.x) . The Tkinter module offers a wide range of widgets that can be used to develop GUI applications much faster and easier compared to the other interfaces offered by Python. The tkinter.ttk module serves as an improvement to the already existing tk module. The Ttk module is equipped with 18 widgets, 12 of which existed in the Tkinter module such as Button, Checkbutton, PanedWindow, Radiobutton, Entry, Frame, Label, LabelFrame, Menubutton, Scale, Scrollbar, and Spinbox. The newly added widgets are Combobox, Notebook, Sizegrip, Progressbar, Separator, and Treeview. In this article, the Notebook widget of ttk module is put into use to create a tabbed widget. The ttk.Notebook widget manages a collection of windows and displays one at a time. Each child window is associated with a tab. The user can select one tab at a time to view the content of the window. Steps to create a tkinter tabbed widget :
import tkinter as tk from tkinter import *Note: Name of the module in Python 2.x is ‘Tkinter’ and in Python 3.x it is ‘tkinter’. Python 3.x is used here.
from tkinter import ttk
root = tk.Tk()Syntax:
Tk()Explanation: Used to create the parent window. Tk class is instantiated without any arguments (here).
root.title("Tab Widget")Syntax:
title(name)Parameter: name: used to pass the desired name to the parent window (root).
tabControl = ttk.Notebook(root)Syntax:
Notebook(master=None, **options)Parameter:
tab1 = ttk.Frame(tabControl) tab2 = ttk.Frame(tabControl)Syntax:
Frame(master=None, **options)Parameter:
tabControl.add(tab1, text='Tab 1') tabControl.add(tab2, text='Tab 2')Syntax:
add(child, **options)Parameter:
tabControl.pack(expand=1, fill="both")Syntax:
pack(**options)Parameter:
ttk.Label(tab1, text="Welcome to GeeksForGeeks").grid(column=0, row=0, padx=30, pady=30) ttk.Label(tab2, text="Lets dive into the world of computers").grid(column=0, row=0, padx=30, pady=30)Syntax:
Label(master, **options)Parameter:
grid(**options)Parameter:
root.mainloop()Syntax: mainloop() Explanation: The mainloop() acts like an infinite loop and is used to run an application.
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.title("Tab Widget")
tabControl = ttk.Notebook(root)
tab1 = ttk.Frame(tabControl)
tab2 = ttk.Frame(tabControl)
tabControl.add(tab1, text ='Tab 1')
tabControl.add(tab2, text ='Tab 2')
tabControl.pack(expand = 1, fill ="both")
ttk.Label(tab1,
text ="Welcome to \
GeeksForGeeks").grid(column = 0,
row = 0,
padx = 30,
pady = 30)
ttk.Label(tab2,
text ="Lets dive into the\
world of computers").grid(column = 0,
row = 0,
padx = 30,
pady = 30)
root.mainloop()
Output
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4