1

Glade 3.14.2 似乎打开了我的 .glade 文件,但什么也没显示。我可以在文本编辑器中查看所有 xml 详细信息。我的 .glade 文件中的标题是:

<?xml version="1.0"?>
<glade-interface>
  <!-- interface-requires gtk+ 2.16 -->
  <!-- interface-naming-policy toplevel-contextual -->
  <widget class="GtkWindow" id="mainwindow">

...以...结尾

</glade-interface>

我是否遗漏了什么或版本错误?

4

1 回答 1

1

It looks like your ui xml is stored in old libglade format.

Since libglade is deprecated, you can try to convert this xml to GtkBuilder format:

gtk-builder-convert foo.glade foo.ui

Note, that gtk-builder-convert is in libgtk2.0-dev package on Debian.

Also note, that you will have to update ui creation code to GtkBuilder too, here goes the skeleton:

import pygtk
pygtk.require("2.0")
import gtk

class Skeleton(object):       
    def __init__(self):
        builder = gtk.Builder()
        builder.add_from_file("foo.ui")
        builder.connect_signals({ "on_window_destroy" : gtk.main_quit })
        self.window = builder.get_object("mainwindow")
        self.window.show()

if __name__ == "__main__":
    Skeleton()
    gtk.main()

You may also try to change root xml element from glade-interface to interface before opening it in recent glade designer, however, I can't recommend that.

于 2013-06-27T09:25:25.907 回答