Is there a way to change the material theme’s colour scheme or title bar colour programmatically?
I have Customer and Supplier main forms (the new ‘Standard page’ layout) in the same app and would like to have the two forms to have different primary colours in the colour scheme.
Thanks @owen.campbell, I am not even close to being able to html or css efficiently enough but… I did find a similar thread (not sure how I didn’t find it before) which provides a work around. Thanks to @andersgs and @stucork for the css role solution.
It is possible to change the colour scheme in code, with a little ingenuity!
You can do it by dynamically updating the CSS. I’ve assembled an app to show you how you can do that, with code you can copy into your own apps. Here’s the clone link:
The ColourChanger module contains some CSS - I got it by taking theme.css and picking every rule that had a %color substitution
The set_theme() function takes that CSS, and substitutes in values for colours such as Primary 500 . It then passes this assembled CSS to the setThemeCss() function, which is written in Javascript.
The setThemeCss() function, which lives in a <script> tag under Native Libraries, is a two-line JS function that inserts a new <style> tag into your page, containing the new colour-changing CSS your Python has assembled.
Form1 shows you how to use this - it’s really simple! Just assemble a dict with the theme colours you want, and call set_theme()
Performing some thread necromancy here. For anyone who stumbles onto this while searching for a solution (like I did), I’ve created an all-Python solution to switch between the built-in color schemes. You can also add your own. Info: