Re: Add tabs to Notebook at runtime, loaded from .glade file?



I understand your problem to be that you have a set of widgets, and you want to instantiate multiple Gtk::Notebook tabs, each containing that same set of widgets, and that you've had to generate and read multiple identical .glade files (each defining a Gtk::Window containing the widget set) to get it working.

If that accurately reflects where you're at, then you're now creating a new Gtk:Builder instance each time you read one of those multiple .glade files, and it's that new instance-per-tab that has made things work. You can go back to using just one .glade file, as long as you continue to create a new Gtk::Builder instance every time you re-read it for a new tab.

You can also dispense with the Gtk::Window if you make your Gtk::Box a top-level widget (in glade, right-click the Gtk::Box icon in the widget pane and select "Add widget as toplevel"). You can then lose the reparent (), and you can prepend_page (), insert_page (), or append_page () the Gtk::Box directly. Also, all of these tab-addition functions have forms that allow specification of the tab title.

See Gtk::Notebook::set_tab_label_text() or get/set_tab_label() if you need to change the title on an existing tab.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]