I’m using the weatherflatsvg preset from the base komponent in kwgt. I want to show the weather icon for the forecast in 3h. I go to the item, globals tab, and set icon to formula. I set the formula to $wf(icon, 0, 3)$. This results in only a placeholder image.
Is this not possible to do, or am I missing something?
First of all, did you create that global variable? Or did it already exist before?
The global variable shown on your screenshot is the one with List type, not Bitmap type. While the element using it is bitmap. So, of you create that global variable, the variable type should be Bitmap instead of List.
Second, the $wf(icon, 0, 3)$ formula is used to display the icon name (text) that is related to the weather forecast, today’s weather forecast in the next 3 hours. In order to show the icon image, you need to define a global variable for each of the possible weather icon names. This variable is a Bitmap type variable, and the variable name should be the same as the icon name indicated by the result of the $wf(icon, 0, 3)$ function.
Third, after you create the global variables for each of the possible weather icon names, on order to select which icon should be used, use this formula for the image filepath:
$gv(wf(icon, 0, 3))$ ➞ the result is the image filepath
The globals are part of the preset (base kwgt komponent WeatherFlatSVG).
I did as you explained. Created a global bitmap for mcloudy. Set the path for the bitmap to kfile://org.kustom.provider/bitmaps/mcloudy.svg as this is the path according to the preset. Set the formula for the icon to $gv(mcloudy)$. This did not work, since as stated this is a preset.
It did give me hope however and after playing around some more I found the steps to unlock the preset and the globals defined within it, et viola, I added the 3h and 6h definitions to the preset’s icon list global and it works!
While the suggestion you provided is correct for other situations but not this one, I do really appreciate you taking the time to answer. It provided motivation to keep trying.