I have a very simple PyGObject application:
from gi.repository import Gtk, Gdk
class Window(Gtk.Window):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_border_width(5)
self.progress = Gtk.ProgressBar()
self.progress.set_fraction(0.5)
self.box = Gtk.Box()
self.box.pack_start(self.progress, True, True, 0)
self.add(self.box)
self.connect('delete-event', Gtk.main_quit)
self.show_all()
win = Window()
Gtk.main()
I want to have the progress bar thicker. So I found that there is a style property for that:
Name Type Default Flags Short Description
min-horizontal-bar-height int 6 r/w Minimum horizontal height of the progress bar
However, I seem not to be able to set the style property in any way I tried.
1) I tried to use CSS:
style_provider = Gtk.CssProvider()
css = b"""
GtkProgressBar {
border-color: #000;
min-horizontal-bar-height: 10;
}
"""
style_provider.load_from_data(css)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
But I got an error:
GLib.Error: gtk-css-provider-error-quark: <data>:4:37'min-horizontal-bar-height' is not a valid property name (3)
2) I tried set_style_property
method and all methods described in this answer to similar question.
a)
self.progress.set_property('min-horizontal-bar-height', 10)
TypeError: object of type 'GtkProgressBar' does not have property 'min-horizontal-bar-height'
b)
self.progress.set_style_property('min-horizontal-bar-height', 10)
AttributeError: 'ProgressBar' object has no attribute 'set_style_property'
c)
self.progress.min_horizontal_bar_height = 10
GLib.Error: gtk-css-provider-error-quark: <data>:4:37'min-horizontal-bar-height' is not a valid property name (3)
d)
self.progress.props.min_horizontal_bar_height = 10
AttributeError: 'gi._gobject.GProps' object has no attribute 'min_horizontal_bar_height'
e)
self.progress.set_min_horizontal_bar_height(10)
AttributeError: 'ProgressBar' object has no attribute 'set_min_horizontal_bar_height'
Any idea how to get thicker progress bar?