Open In App
Related Articles

Python – Notebook in GTK+ 3

Improve Article
Save Article
Like Article

The Gtk.Notebook widget is a Gtk.Container whose children are pages that can be switched between using tab labels along one edge.

Configuration options for GtkNotebook.

  1. Gtk.Notebook.set_tab_pos() for choosing which edge the tabs should appear.
  2. Gtk.Notebook.set_scrollable() for making notebook bigger and for adding scrolling options.
  3. Gtk.Notebook.popup_enable(), Gtk.Notebook.popup_disable() for whether there will be a popup menu allowing the users to switch pages

Follow below steps:

  • import GTK+ 3 module.
  • Create Notebook.
  • Create Box.


import gi
# Since a system can have multiple versions
# of GTK + installed, we want to make 
# sure that we are importing GTK + 3.
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
class MyWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title ="Geeks for Geeks")
        # Create Notebook
        self.notebook = Gtk.Notebook()
        # Create Boxes
        self.page1 = Gtk.Box()
        self.page1.add(Gtk.Label("Welcome to Geeks for Geeks"))
        self.notebook.append_page(self.page1, Gtk.Label("Click Here"))
        self.page2 = Gtk.Box()
        self.page2.add(Gtk.Label("A computer science portal for geeks"))
        self.notebook.append_page(self.page2, Gtk.Label("Click Here"))
win = MyWindow()
win.connect("destroy", Gtk.main_quit)
# Display the window.
# Start the GTK + processing loop

Output :

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 03 Jun, 2020
Like Article
Save Article
Similar Reads
Complete Tutorials