How to set a range for percentage slider?
#1
I have a slider in my add-on settings like this:

Code:
<setting label="..." type="slider" id="limit" default="1" range="0,0.1" option="percent"/>

I want to set the range to 1%-10% in 1% steps default 1%

I tried some things but every time the slider goes up to 100%.

Does anybody know how to limit the range of a percentage slider?
Reply
#2
Look at the dim screensaver and adjust the numbers accordingly.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#3
thanks for the idea, but for me the slider of the dim screensaver doesn't work either...

does it work for you?
Reply
#4
no it sure doesn't, percent must default it to 0-100.

They just did a major settings overhaul for XBMC. I don't know if their plan is to bring that to addons or not. even if it is. maybe some of this branch could be useful, especially the part that formats the slider. It allows formatting the minimum, maximum and normal values seperately.

https://github.com/nuka1195/xbmc/tree/Br...n_Settings


PHP Code:
// Sample: <setting id="mysettingname" type="slider" label="30000" range="5,5,60" format="%1f. msec,min,max" option="int" default="5"/>
      // to make ints from 5-60 with 5 steps formatted as min when==5, max when==60 or 25 msec

void CGUIDialogAddonSettings::SetSliderTextValue(const CGUIControl *control, const char *format)
{
  if (!
format)
    return;

  
CStdString strValue;
  
vector<CStdStringformats;
  
StringUtils::SplitString(format","formats);

  if (
formats.size() == && !formats[2].IsEmpty() && ((CGUISettingsSliderControl *)control)->GetProportion() == 1.0f)
    
strValue.Format(GetString(CleanString(formats[2])).c_str(), ((CGUISettingsSliderControl *)control)->GetFloatValue());
  else if (
formats.size() >= && !formats[1].IsEmpty() && ((CGUISettingsSliderControl *)control)->GetProportion() == 0.0f)
    
strValue.Format(GetString(CleanString(formats[1])).c_str(), ((CGUISettingsSliderControl *)control)->GetFloatValue());
  else
    
strValue.Format(GetString(CleanString(formats[0])).c_str(), ((CGUISettingsSliderControl *)control)->GetFloatValue());

  ((
CGUISettingsSliderControl *)control)->SetTextValue(strValue);

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#5
looks interesting, I hope it will be acceptedSmile
Reply

Logout Mark Read Team Forum Stats Members Help
How to set a range for percentage slider?0