Skip to Content
Tkinter GUI Programming by Example
book

Tkinter GUI Programming by Example

by David Love
April 2018
Beginner content levelBeginner
340 pages
7h 54m
English
Packt Publishing
Content preview from Tkinter GUI Programming by Example

The Notebook widget

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788627481Supplemental Content