在python中没有GTK3的“HeaderBar”属性

时间:2014-01-09 10:26:35

标签: python gtk gtk3

我有这个简单的窗口 -

from gi.repository import Gtk

class Simplicity(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self)

        hb = Gtk.HeaderBar()
        hb.props.show_close_button = True
        hb.props.title = "HeaderBar example"
        self.set_titlebar(hb)

        self.connect("delete-event", Gtk.main_quit)

window = Simplicity()
window.show_all()

Gtk.main()

但是当我运行它时,它会给我一个错误 -

Traceback (most recent call last):
  File "simplicity.py", line 17, in <module>
    window = Simplicity()
  File "simplicity.py", line 10, in __init__
    hb = Gtk.HeaderBar()
  File "/usr/lib/python2.7/dist-packages/gi/module.py", line 243, in __getattr__
    return getattr(self._introspection_module, name)
  File "/usr/lib/python2.7/dist-packages/gi/module.py", line 105, in __getattr__
    self.__name__, name))
AttributeError: 'gi.repository.Gtk' object has no attribute 'HeaderBar'

发生了什么事?我看到了这个例子here

1 个答案:

答案 0 :(得分:2)

GTK +提供GtkHeaderBar since GTK 3.10。您最有可能使用旧版本的GTK 3.检查您的计算机上是否运行unmodified example program