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