Veja um exemplo que tem contexto
from gi.repository import Gtk
class Handler:
def onDeleteWindow(self, *args):
Gtk.main_quit(*args)
def addNotebookClick(self, *args):
vbox = builder.get_object("attachtome")
mynote = builder.get_object("notebook1")
temp = Gtk.Box()
mynote.reparent(temp)
vbox.pack_start(temp, expand=False, fill=False, padding=0)
window.show_all()
builder = Gtk.Builder()
builder.add_from_file("howtoaskaprogrammingquestion.glade")
builder.connect_signals(Handler())
window = builder.get_object("window1")
window.show_all()
Gtk.main()
Funciona com este arquivo glade
Ele fornece essa funcionalidade:
IssotambémfuncionasevocêestiverusandoseupróprioNotebook.Observeque,quandovocêexecutaoexemplo,vêumapequenaalteraçãonageometriadajanela(oobjetoqueestásendoadicionado),maselanãoaparecepararenderizarporqueaindanãotemguias.
fromgi.repositoryimportGtkclassHandler:defonDeleteWindow(self,*args):Gtk.main_quit(*args)defaddNotebookClick(self,*args):vbox=builder.get_object("attachtome")
mynote = Gtk.Notebook()
#mynote = builder.get_object("notebook1")
#temp = Gtk.Box()
#mynote.reparent(temp)
vbox.pack_start(mynote, expand=False, fill=False, padding=0)
window.show_all()
builder = Gtk.Builder()
builder.add_from_file("howtoaskaprogrammingquestion.glade")
builder.connect_signals(Handler())
window = builder.get_object("window1")
window.show_all()
Gtk.main()