Reputation: 315
According to the official documentation (https://developer.gnome.org/gtk3/stable/GtkHeaderBar.html), GtkHeaderBar
has a spacing property.
To change the subtitle and title properties in python you would use
headerbar.set_title()
headerbar.set_subtitle()
So it should therefore follow that spacing()
would also follow the same rules, however I am informed of the following error
AttributeError: 'HeaderBar' object has no attribute 'set_spacing'
What is the reason for this? I have not been able to find any specific examples, the documentation is the only place that covers its use, and according to it spacing
is clearly a property of GtkHeaderBar
Appreciate any help you can give here
Upvotes: 0
Views: 167
Reputation: 57854
To set GObject properties directly, each object has a props
attribute:
headerbar.props.spacing = 5
headerbar.props.subtitle = 'Habits of the Algorithmic Mind'
I believe this is so that when you mistype a property name it won't silently fail (e.g. headerbar.spaing = 5
). Although other language bindings for GObject, such as JS and Ruby, treat GObject properties the same as attributes of the object.
Upvotes: 4
Reputation: 5440
Properties are not the same as attributes. You can set the property with:
your_bar.set_property("spacing", 5)
Or, you can define the spacing on instantiating the object:
your_bar = Gtk.HeaderBar(spacing = 5)
(I prefer the latter - you can set a bunch of properties that way, in one single statement)
Upvotes: 1