Hello everyone! Is there a way to show on the screen labels instead of numbers, when changing slider of param.Integer() object?
class A(param.Parameterized):
a = param.Integer(0, bounds=(0, 5), label=‘Should be labels not numbers’)
pn.Column(A())
I expect integer value as a return while interacting, but on screen would like to see labels instead of 0,1,2,3,5. Thanks in advance!
Marc
2
Hi @JhonnyKokos
Is it something like this you are looking for?
import param
from bokeh.models.formatters import PrintfTickFormatter
import panel as pn
pn.sizing_mode = "stretch_width"
class MyDucksComponent(param.Parameterized):
value = param.Integer(1, bounds=(1, 5))
# C.f. https://panel.holoviz.org/reference/widgets/IntSlider.html?highlight=intslider
value_format = PrintfTickFormatter(format="%d Ducks")
component = MyDucksComponent()
value_slider = pn.Param(component, widgets={"value": {"format": value_format}})[1]
@pn.depends(value=value_slider)
def duck_string(value):
return pn.pane.Str("🦆 " * value, height=50)
pn.template.FastListTemplate(
title="Panel - Slider with dynamic label", main=[value_slider, duck_string]
).servable()
1 Like
Thank you Sir! This is exactly what I was looking for!
1 Like
Is there a way to apply a default formatting to all widgets being rendered?