Using Files with Multiple Glades: GtkBuiler

I am writing an application for gnome that will support plugins. Each plugin will contain a glade file and a python script.

How to insert a glade file from a plugin into the main interface.

Plugin plugin files must contain a page / tab and be embedded in the laptop in the main interface.

Please, help.

+3
source share
2 answers

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

+3

:

  • glade GtkBuilder, . pluginbox, mynotebook. :

    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)
    
  • . , :

    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)
    
+2

Source: https://habr.com/ru/post/1716890/


All Articles