April 2018
Beginner
340 pages
7h 54m
English
The Notebook widget is only available in ttk, rather than the regular Tkinter. The widget is used to create a tabbed interface for displaying multiple Frame widgets in one window. A small example will demonstrate this nicely:
import tkinter as tkimport tkinter.ttk as ttkwin = tk.Tk()win.geometry("400x400")n = ttk.Notebook(win)frame_one = ttk.Frame(n)frame_two = ttk.Frame(n)label_one = ttk.Label(frame_one, text="We are in frame 1")label_two = ttk.Label(frame_two, text="We are in frame 2")
We create an instance of the Notebook widget, then two Frame widgets to act as tabs.
Inside these two Frame widgets will be a Label widget which informs us which Frame we are seeing.
We now need to add these Frame widgets to our Notebook ...