PyGTK Notebook Class - PyGTK

What is PyGTK Notebook Class?

Notebook widget is a tabbed container. All tabs in this container grips a dissimilar page and the pages are seen in overlapped manner. Any preferred page is made noticeable by clicking on the label of the tab. The labels can be arranged to be shown on top or bottom or to the left or right. A container widget with other widgets placed in it or a single widget is placed under each page.

If data to be showed is too big in one view, it is gathered in different pages, each placed under one tab of a Notebook widget. This type of switch is very widely used. Internet browser for example, uses this tabbed show for rendering different pages in different tabs.

The resulting is a constructor of the gtk.Notebook class –

The resulting are the regularly used methods of the gtk.Notebook class −

  • append_page(child, label) − This appends a page to the notebook containing a widget stated by tab_label as the label on the tab. If tab_label can be None to use a default label.
  • insert_page(child, label, position) − This inserts a page into the notebook at the location stated by position.
  • remove_page(index) − This removes a page at the stated index.
  • get_current_page() − This returns the page index of the current page.
  • set_current_page(index) − This switches to the page number stated by the index.
  • set_show_tabs() − If false, tabs will not be visible. This is True by default.

set_tab_pos(pos) − This sets the edge at which the tabs for switching pages in the notebook are drawn. The predefined constants are −

  • gtk.POS_LEFT
  • gtk.POS_RIGHT
  • gtk.POS_TOP
  • gtk.POS_BOTTOM
  • set_tab_label_text(child, text) − This creates a new label with the text stated and sets it as the tab label for the page containing child.

The gtk.Notebook widget emits the resulting signals −


This is emitted when the page forward or page backward request is issued


This is emitted when the focus is changed by tabbing.


This is emitted when a page is added to the notebook.


This is emitted after a page is removed from the notebook.


This is emitted when a new child page is selected.


This is emitted when the notebook page is changed.


In the resulting instance, a gtk.Notebook with three pages is located in a toplevel gtk.Window. The first page holds a VBox in which a label and Entry field is packed. The second page labelled 'qualifications' has a HButtonBox in which three mutually exclusive RadioButton widgets are added. The third page has a TextView object. The page labels are shown at top.

Observe the code –

Upon implementation, the above code shows a Notebook with three pages –



All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

PyGTK Topics