 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- 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.

Advertisements
 