Reputation: 868
I want to change the background color of my Gtk.Entry widget to red, to display that there's an error in this field.
I've found several methods how to accomplish this.
entry.modify_bg -> no change
entry.override_bg -> no change
entry.modify_base -> no change
Whats the correct way to do this?
Upvotes: 4
Views: 2562
Reputation: 57854
You can use entry.override_background_color(Gtk.StateFlags.NORMAL, ...)
(not override_bg()
) or you can create some CSS:
provider = Gtk.CssProvider()
provider.load_from_data('.entry { background: red; }')
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
Upvotes: 5