When I add a page to a Gtk.Notebook programatically, I can't find a way to set the tab to expand. The property is available in Glade, so I know it can be done. Here is a snippet using reorderable
and detachable
properties.
#!/usr/bin/env python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class GUI:
def __init__(self):
window = Gtk.Window()
notebook = Gtk.Notebook()
window.add(notebook)
for i in range (4):
label = Gtk.Label('label in page number ' + str(i))
tab_label = Gtk.Label('page ' + str(i))
notebook.append_page(label, tab_label)
notebook.set_tab_detachable(label, True)
notebook.set_tab_reorderable(label, True)
window.show_all()
window.connect('destroy', Gtk.main_quit)
app = GUI()
Gtk.main()
However,
notebook.set_tab_expandable(label, True)
fails with
AttributeError: 'Notebook' object has no attribute 'set_tab_expandable'
The solution is:
notebook.child_set_property(label, 'tab-expand', True)