Home > Net >  How do I make a Gtk button "highlighted"?
How do I make a Gtk button "highlighted"?

Time:11-14

I notice that in many of the system dialogs on Ubuntu, there is a button (usually Open, Save, etc.) that is a different color than normal. But also, these buttons' colors change with the system theme; in Adwaita, they are blue. In Yaru, they are green. So no, I'm not asking how to set the background of a button to a specific color.

My question is, how do I make a button "highlighted" according to the current theme without having to manually set the color? Is it even possible to do this in Python? I've looked in Gtk, Gtk.Dialog, GtkSource, Gdk, GLib, and Pango, and found nothing. Ideally, the solution would work for any button, not just a button in a dialog.

CodePudding user response:

You can use StyleContext to highlight widget. Gtk widgets such as Gtk.Button that inherits from Gtk.Widget can obtain its StyleContext by calling enter image description here

  • Related