[Glade-users] [Glade-devel] how to add window as a page to a notebook

Tristan Van Berkom tvb at gnome.org
Mon Jan 12 23:44:49 EST 2009


On Sat, Jan 10, 2009 at 1:54 AM, anusha k <anuhacks at gmail.com> wrote:
> hi,
>
> I am using glade and pygtk to develop an accounting software.In that we have
> two glade files .first glade file contain the main window and the note book
> and the second glade contains the another window .I want to add the second
> glade-window as a page to first glade-window.how to do this
> I have the code as below.but it is giving the warning and the window is not
> shown up .warnings are :
> How to solve the warnings.Is there any other way to solve this
> Warnings:****************************************************************************
>
> self.wTree = gtk.glade.XML(self.gladefile)
> main.py:47: GtkWarning: gtk_notebook_set_tab_label: assertion `GTK_IS_WIDGET
> (child)' failed
>   self.wTree = gtk.glade.XML(self.gladefile)
> main.py:20: GtkWarning: Can't set a parent on a toplevel widget
>
>
> self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget("window_new_org")
> , None, 0)
> main.py:20: GtkWarning: gtk_widget_set_child_visible: assertion
> `!GTK_WIDGET_TOPLEVEL (widget)' failed

You cannot add a GtkWindow to another GtkContainer, a GtkWindow is a
toplevel-only
widget and is not meant to be maintained.

You can either:
   - Manually unparent your window's child and add that child to the
notebook (the traditional oldschool way)
   - Use the "root" argument to glade_xml_new or some equivalent
gtkbuilder api (I think that works
     for building of sub-portions of the glade file)
   - Use development or trunk versions of Glade allowing you to use
non-GtkWindow toplevel project
     widgets - and use GtkBuilder that will allow you toplevelless
glade files without errors/warnings.

Cheers,
                   -Tristan

>
> self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget("window_new_org")
> , None, 0)
> ***************************************************************************
> Code:
>
> import pygtk
> pygtk.require('2.0')
> import gtk
> import gtk.glade
> import new_org
> class mainmenu:
>     def show_newOrganisation(self,widget):
>         new_org.org()
>         self.gladefile_newOrg = "new_org.glade"
>         self.wTreenewOrg = gtk.glade.XML(self.gladefile_newOrg)
>
> self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget("window_new_org")
> , None, 0)
>         self.notebook.set_current_page(self.page)
>
>     def dialogQuit(self,widget):
>         self.dialog_quit = self.wTree.get_widget("dialog_quit")
>         self.dialog_quit.show()
>         self.response = self.dialog_quit.run()
>         if self.response == 'gtk.RESPONSE_QUIT':
>             gtk.main_quit()
>             self.window.destroy()
>         self.dialog_quit.destroy()
>
>
>     def on_button_quit_clicked(*args):
>         gtk.main_quit()
>
>     def on_button_cancel_clicked(*args):
>         self.dialog_quit.destroy()
>
>     #To quit the main window
>     def on_Mainwindow_destroy(self):
>         gtk.main_quit()
>
>
>     def __init__(self):
>         #set the glade file
>         self.gladefile = "gnukhata.glade"
>         self.wTree = gtk.glade.XML(self.gladefile)
>
>         #get the Main Window and connect the Destroy event
>         self.window = self.wTree.get_widget("MainWindow")
>         self.window.show()
>         self.window.connect('destroy',gtk.main_quit)
>         self.notebook = self.wTree.get_widget("notebook_main")
>         self.notebook.show()
>
>         self.menuitem_quit = self.wTree.get_widget("menuitem_quit")
>         self.menuitem_quit.connect('activate',self.dialogQuit)
>
>         self.menuitem_newOrg =
> self.wTree.get_widget("menuitem_new_organisation")
>         self.menuitem_newOrg.connect('activate',self.show_newOrganisation)
> if __name__ == "__main__":
>     mm=mainmenu()
>     gtk.main()
>
> Thanks in advance
>
> Njoy the share of Freedom,
> Anusha
>
> _______________________________________________
> Glade-devel maillist  -  Glade-devel at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/glade-devel
>
>


More information about the Glade-users mailing list