Linking slider to argument of a function


I’m new to panel and most likely have a misunderstanding. Hope somebody can help me.

I have a function with an argument and I want to link that argument to a slider.

Here is a very simplified example:

def my_func(argument):
    # complex operations based on the argument, not shown here

func_inst = my_func(argument=5)

arg_slider = pn.widgets.IntSlider(start=0,end=19,value=10),value='argument')


This shows the slider and the initial result (from argument 5), but when I move the slider, the function is not recalculated.

I know that there are different ways to do this, e.g. via “interact”. For the example I have, interactive causes a few headaches, as I have multiple sliders and need to put them in different places on the panel.

I am not sure if “link” really supports a handling as I’m looking for, i.e. if it can link a slider and a function-argument. Please just say if that is not possible.

Thanks for your help!


I think you need bind your function to the arguments. Link is used to link two different widgets or parameters.,value=‘argument’)


pn.bind(my_func, arg_slider)

a most detailed explanation can be found in the getting started section ()

1 Like

Another good introduction to panel is Introduction to data apps with Panel, Pydata Copenhagen, March 2022 - YouTube by @Marc.

Where he goes over a very similar example.


Welcome to the community @grgmyr

Thanks for asking your questions here. It will also help the next user trying to get started with Panel and help guide the documentation overhaul which is on the roadmap.

1 Like

Thank you all so much! This did the job and I am amazed who simple and clean everything can be done by using bind - I thought much too complicated. Thanks also for the video link, this was also helpful.