tags:

views:

227

answers:

2

I'm writing an app for gnome which will support plugins. Each plugin will contain a glade file and a python script.

How do I embed the glade file from the plugin in the main interface.

Plugin glade files should contain a page/tab and will be embeded into a notebook in the main interface.

please help.

+1  A: 

The best way would be to make the plugins load the glade file themselves and have a function that the main program can call to get the page/tab. That way the plugin can connect all the signals it needs to. gtk.Builder documentation.

DoR
+1  A: 

You have two options:

  1. You can open the two glade files into two different GtkBuilder objects, and then manually add the content of the plugin file into the main window. You could put the content of the plugin into a box named 'pluginbox' and the notebook of your main app would be named 'mynotebook'. In code should look like this:

    main_builder = gtk.Builder() main_builder.add_from_file('main.glade')

    plugin_builder = gtk.Builder() plugin_builder.add_from_file('plugin.glade')

    mynotebook = main_builder.get_object('mynotebook') pluginbox = plugin_builder.get_object('pluginbox') mynotebook.append_page(pluginbox)

  2. You can add different files to one builder. You should be sure that there is no conflict with names in the two files:

    main_builder = gtk.Builder() main_builder.add_from_file('main.glade') main_builder.add_from_file('plugin.glade')

    mynotebook = main_builder.get_object('mynotebook') pluginbox = main_builder.get_object('pluginbox') mynotebook.append_page(pluginbox)

Manuel Ceron