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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With