Notebook / tabbed Widget in tkinter.ttk
ttk :: Notebook Widget
Notebook widget is a widget of tkinter.ttk class and it is used for creating tab in your GUI .
Notebook widget is also known as tabbed widget because of it output.
So lets Code.
# Tkinter - Dynamic Coding
# Image on canvas widget ..
# Import Library
from tkinter import *
from tkinter import ttk
main = Tk()
main.title('Dynamic Coding - Notebook')
main.geometry('500x500')
# Defines and places the notebook widget
nb = ttk.Notebook(main)
nb.pack(expand=1, fill="both")
# Adds tab 1 of the notebook
page1 = ttk.Frame(nb)
nb.add(page1, text='Tab1')
# Adds tab 2 of the notebook
page2 = ttk.Frame(nb)
nb.add(page2, text='Tab2')
# Adding contents on frame .
Label(page1,text='You are in Frame 1.',font=('arail',15,'bold')).pack(pady=100)
Label(page2,text='You are in Frame 2.',font=('arail',15,'bold')).pack(pady=100)
main.mainloop()
How the code works .
In the Above code first we create a Notebook widget instance named nb and pack it.
After that we create 2 frames and add each frame one by one using nb.add( ) method of notebook.
📓Note : You can only add Frame to a Notebook object not all widgets.
.
Output.
you can check out our Tkinter tutorial series .
and leave a comment whether it is useful for you or not .
.
Recommended Posts:
Thank you ..
If have Any doubts and Errors , comment section is open for you and we will try to solve your doubts as soon as possible.
No comments