Return int value but show labels on the screen insead of int for param.Integer()

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’)

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!

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.
value_format = PrintfTickFormatter(format="%d Ducks")

component = MyDucksComponent()
value_slider = pn.Param(component, widgets={"value": {"format": value_format}})[1]

def duck_string(value):
    return pn.pane.Str("🦆 " * value, height=50)

    title="Panel - Slider with dynamic label", main=[value_slider, duck_string]
1 Like

Thank you Sir! This is exactly what I was looking for!

1 Like