sugar3.graphics.notebook module

Notebook class

This class creates a Gtk.Notebook widget supporting a close button in every tab when the can-close-tabs gproperty is enabled (True).

from gi.repository import Gtk

from sugar3.graphics.notebook import Notebook
from common import set_theme
set_theme()


w = Gtk.Window()
w.connect("delete-event", Gtk.main_quit)

box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
w.add(box)

nb = Notebook(can_close_tabs=True)
box.pack_start(nb, False, False, 0)

for i in range(5):
    bufferf = "Prepend Frame %d" % (i + 1)
    bufferl = "PPage %d" % (i + 1)

    frame = Gtk.Frame()
    frame.set_border_width(10)
    frame.set_size_request(100, 75)
    label = Gtk.Label(bufferf)
    frame.add(label)
    label.show()
    nb.add_page(bufferl, frame)
    frame.show()

w.show_all()

Gtk.main()
class sugar3.graphics.notebook.Notebook(**kwargs)

Bases: gi.repository.Gtk.Notebook

Notebook class that creates a Gtk.Notebook. It is possible to set the can-close-tabs property from the constructor through Notebook(can_close_tabs=True)

add_page(text_label, widget)

Adds a page to the notebook and sets the newly added page as current. Returns True if the page is successfully added to the notebook. If can-close-tabs is true, then a GtkEventBox is also created to close the tab.

Parameters
  • text_label (string) – label of page to be added

  • widget (Gtk.Widget) – widget to be used as contents of current page

do_set_property(pspec, value)

Implementation method. Use notebook.props to set properties.