Search code examples
pythongtkpygobject

PyGObject Gtk.Entry Changing progress bar color


I want to change the color of the progress bar of the Gtk.Entry widget but am unable to do so by using Gtk.Widget.override_color(). How can I do this?


Solution

  • In pygtk, you have to override the GtkStyle of the widget. In the case of the GtkProgressBar the color of the bar is determined by the bg attribute's Gtk.STATE_PRELIGHT of its style component. Source

    So you could do something like:

    progress_bar.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse("blue"))
    

    I'm sure something similar can be applied in PyGObject.

    Note: You are overriding style settings in Gtk which should be avoided. Styles and themes should be left up to the end user for their own personal tastes.