<https://lh3.googleusercontent.com/-pmvgphGF1cE/WVOvKnRURSI/AAAAAAAACYQ/2gnre5UtQeoJuOAsmjCeulMii4V8TJqfACLcBGAs/s1600/Screenshot%2B2017-06-29%2B01.28.52.png>


Great thanks, got that sorted now.
Will tidy up a bit more and post here for comments




On Wednesday, 28 June 2017 02:05:24 UTC+12, Tom Keffer wrote:
>
> It's a subtle point. The key is that UV_color (and UV_text) have to be 
> *functions*, so your search list extension has to return something that 
> evaluates to a function. Something like this (NOT TESTED):
>
>
> from weewx.cheetahgenerator import SearchList
>
> # Given a UV value, this function will return an appropriate color
> def get_uv_color(value):
>     if value > 5.0:
>         return "red"
>     else:
>         return "blue"
>
> class MyUV(SearchList):
>
>     def __init__(self, generator):
>         SearchList.__init__(self, generator)
>
>     def get_extension_list(self, timespan, db_lookup):
>         return [{'UV_color' : get_uv_color}]
>
>
> Now when Cheetah scans the search list, looking for 'UV_color', it will 
> get a hit with class MyUV. What gets returned is a function, which it then 
> calls with your value as a parameter.
>
> -tk
>
> On Tue, Jun 27, 2017 at 1:29 AM, Neil Trimboy <[email protected] 
> <javascript:>> wrote:
>
>> Tom,
>>
>> Thanks for the pointer.
>> I've made some progress with this but none of the search list extension 
>> examples  in the Customisation guide and those I can find referenced in 
>> GoogleGroup and in other extensions seem to pass a parameter from the 
>> webpage.html.tmpl
>>
>> So I have got an extension working, filling in a (hardcoded) coloured 
>> <td> cell as I wanted along with passing configuration in from skin.conf
>>
>> but I am unable (=don't know how) to pass the actual value down to and 
>> receive in my function.
>>
>> ie 
>> I can do
>> <td class="stats_data" style="background-color: $UV_color">$current.UV
>> </td>
>>
>> but am struggling on
>> <td class="stats_data" style="background-color: 
>> $UV_color($current.UV.raw)">$current.UV</td>
>>
>> any pointers appreciated, thanks
>>
>> On Monday, 26 June 2017 01:34:28 UTC+12, Tom Keffer wrote:
>>>
>>> There's an example in the Wiki 
>>> <https://github.com/weewx/weewx/wiki/Colored%20UV%20index> of how to do 
>>> this, but I don't think it's particularly efficient. 
>>>
>>> A search list extension would probably be the most elegant. Then you 
>>> could do something like:
>>>
>>>   <tr>
>>>     <td class="stats_label">UV</td>
>>>     <td class="stats_data" style="background-color: 
>>> $UV_color($current.UV.raw)">$current.UV $UV_text($current.UV.raw)</td>
>>>   </tr>
>>>
>>> The functions $UV_color() and $UV_text() would return an appropriate 
>>> color and warning, respectively, depending on their argument. An elegant 
>>> touch would be for $UV_text() to get its strings out of skin.conf, 
>>> making it easy to internationalize the text.
>>>
>>> -tk
>>>
>>>
>>> On Sun, Jun 25, 2017 at 3:06 AM, Neil Trimboy <[email protected]> 
>>> wrote:
>>>
>>>> Just wondering if embedding these colour mappings inside templates is 
>>>> the correct way to solve the problem.?
>>>>
>>>> There are several instances when this may be wanted : UV, Heat Index, 
>>>> HumidyIndex and others all of which have, I believe, standardised colours 
>>>> for defined ranges AND standardised textual descriptions (ie Danger - see 
>>>> http://www.nws.noaa.gov/om/heat/heat_index.shtml)
>>>>
>>>> I would suspect the elegant way to solve this might be to extend 
>>>> something in units.py ?
>>>>
>>>> Any thoughts or pointers from any experts for me to dabble with 
>>>> appreciated. Thanks
>>>>
>>>>
>>>> On Sunday, 4 January 2015 20:32:17 UTC+13, Liz wrote:
>>>>>
>>>>> I've been playing with this on the standard skin, and have left 
>>>>> further 
>>>>> comments on the wiki 
>>>>> https://sourceforge.net/p/weewx/wiki/Colored%20UV%20index/ 
>>>>>
>>>>> I had some problems with the wiki formatting, which just wouldn't let 
>>>>> me put in an example of code to change the font colour. I thought that 
>>>>> red font on red background wasn't going to be useful, and switched all 
>>>>> of mine to black font. 
>>>>>
>>>>> Liz 
>>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "weewx-user" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to