- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Notebook widget in Tkinter
Notebook widget is an inbuilt widget of ttk library in tkinter. It enables the user to create Tabs in the window application. Tabs are generally used to separate the workspace and specialize the group of operations in applications at the same time.
Example
In this example, we will create two tabs using Notebook widget and then will add some context to it.
#Import the required library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() win.geometry("750x250") #Create a Notebook widget my_notebook= ttk.Notebook(win) my_notebook.pack(expand=1,fill=BOTH) #Create Tabs tab1= ttk.Frame(my_notebook) my_notebook.add(tab1, text= "Tab 1") tab2= ttk.Frame(my_notebook) my_notebook.add(tab2, text= "Tab2") #Create a Label in Tabs Label(tab1, text= "Hello, Howdy?", font= ('Helvetica 20 bold')).pack() Label(tab2, text= "This is a New Tab Context", font=('Helvetica 20 bold')).pack() win.mainloop()
Output
Running the above code will display a window containing two tabs, tab1 and tab2 respectively. Tabs contain some Text Labels in it.
Now, switch to "tab1" and then "tab2" to see the changes between the two tabs.
- Related Articles
- Using Tkinter in Jupyter Notebook
- Progressbar widget in Python Tkinter
- Underline Text in Tkinter Label widget
- How to center a Tkinter widget?
- Tkinter Spinbox Widget Setting Default Value
- Dynamically change the widget background color in Tkinter
- How to use the Entry widget in Tkinter?
- How to update a Button widget in Tkinter?
- Getting the Cursor position in Tkinter Entry widget
- How to disable an Entry widget in Tkinter?
- Vertical and Horizontal Scrollbars on Tkinter Widget
- Get contents of a Tkinter Entry widget
- How to set focus for Tkinter widget?
- How to make a Tkinter widget invisible?
- How to remove Ttk Notebook Tab Dashed Line? (tkinter)

Advertisements