Use glade with pygobject Gtk3

前端 未结 2 1525
情话喂你
情话喂你 2021-02-07 22:41

I am converting a script to use Gtk3 using the migration guide (Porting GTK2 to GTK3). I converted my import pygtk to a from gi.repository import Gtk a

相关标签:
2条回答
  • 2021-02-07 22:59

    Well, the solution is pretty obvious, after calling to Gtk.Builder() one needs to convert the old glade interface with the gtk-builder-convert command to get the interface file in the right version.

     $ gtk-builder-convert myui.glade myui.ui
    

    And then, in the python script:

     from gi.repository import Gtk
     builder = Gtk.Builder()
     builder.add_from_file("myui.ui")
    

    Thanks to Riccardo.

    0 讨论(0)
  • 2021-02-07 23:13

    This should work

    from gi.repository import Gtk
    builder = Gtk.Builder()
    builder.add_from_file("project.xml")
    
    0 讨论(0)
提交回复
热议问题