[Gambas-user] Explanations about stock icons and dark theme

Benoit Minisini benoit.minisini at gambas-basic.org
Tue Feb 21 00:40:09 CET 2023

Le 20/02/2023 à 23:41, Gianluigi a écrit :
> Hi Benoit,
> Frankly, despite your kind explanation, I did not understand and I 
> apologize. Why did the attached project, the first time I launched it
> with the stable version, worked only with the normal theme and not
> with the dark theme? 

'Application.DarkTheme' is set when a dark theme is detected. Then the 
'Stock[]' method tries to adapt.

Then, if a desktop icon theme is detected, and if that desktop icon 
theme has an icon associated with the requested icon name, then that 
icon is returned, -whatever the value of Application.DarkTheme-. Because 
desktop icon themes do not adapt to dark theme. You are supposed to 
choose a desktop icon theme adapted to dark theme.

If no desktop icon theme is detected, or if desktop icon theme has no 
icon associated with the requested icon name, then the default icons 
stored in the 'gb.form.stock' are automatically used, and then 
-Application.DarkTheme is taken into account-.

 > [...]
> Could you please give a small example demonstrating how the image of
> a button should be set up so that anyone who starts the program
> whatever the theme sees the same icon drawn the same way even if with
> different colors?

If you want the button icon to be the same whatever the theme, then 
don't use the Stock class or Picture["icon:/..."]!


Benoît Minisini.

More information about the User mailing list