Using query parameters without param

Hey there,
I’m curious whether it is possible to use query parameters (see Access and Manipulate the URL with pre-existing code featuring “regular” panel widgets.

E.g., I’m using the TextInput widget and want to link it to a query parameter.

textinput_file_path = pn.widgets.TextInput(
    name="File/Folder name contains:", placeholder="Enter search string..."
)

I was trying to link create a intermediate param variable and update both the widget variable and the param variable via depends, but this doesn’t seem to work:

textinput_file_path = pn.widgets.TextInput(
    name="File/Folder name contains:", placeholder="Enter search string..."
)

class Settings(param.Parameterized):
    file_path = param.String(default="")

    @param.depends('file_path', watch=True)
    def update_textinput_file_path(self):
        textinput_file_path.param.value = entry_name.value

@pn.depends(textinput_file_path.param.value, watch=True)
def update_query_parameter(value, **kwargs):
    settings.file_path.value = value


settings = Settings()
pn.state.location.sync(settings, {'file_path': 'file_path'})

Any ideas?

I discovered Sync Widgets and URL — Panel v1.5.3 and it worked out.

1 Like