Question

I have this simple window -

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()

But when I run it, it gives me a error -

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'

What is happening? I saw this example here

Was it helpful?

Solution

GTK+ provides GtkHeaderBar since GTK 3.10. You're most likely using an older version of GTK 3. Check that the unmodified example program runs on your machine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top