0

In the app I'm building, I have a variable with a hex colour code:

accentColour = "#0877df"

This value can be changed by the user.

Since I'm using GTK+3, I'm using a CSS file to style the widgets. How can I pass the accentColour variable to use as a colour in CSS?

Kavaeric
  • 43
  • 1
  • 6

1 Answers1

0

You can't. Instead, I would put only the default color in your CSS file. Then make a CSS string in your code that overrides only the things that are affected by the color change, and add it in a separate CSS provider.

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • I don't think I've ever done inline CSS strings like that, how would I go about it? If it's a string, do I simply concatenate strings together? – Kavaeric Nov 13 '16 at 17:28
  • Yes, you can load a string containing CSS code just as you can load a file containing CSS code: http://lazka.github.io/pgi-docs/index.html#Gtk-3.0/classes/CssProvider.html#Gtk.CssProvider.load_from_data – ptomato Nov 13 '16 at 20:20