Panel Tabulator passes the values of the selected row to another function

I am building a panel app and hit a block. What I want to accomplish is to pass certain values of the row selected from the dataframe visualized by Tabulator widget to another function, which is responsible for loading another dataframe and producing predefined plots based on these values. I can manage to get to the point where the selection event gives me the required data, but how can I link the updated values to the input of another function. How can I make the function monitor the selection result and perform its task dynamically? Part of this code:

import pandas as pd import panel as pn from panel.widgets import Tabulator pn.extension('tabulator') def click(event): print(df_parameters_short.iloc[event.row]['TIC_ID']) print(df_parameters_short.iloc[event.row]['modes']) selected_tic_id = df_parameters_short.iloc[event.row]['TIC_ID'] selected_mode = df_parameters_short.iloc[event.row]['modes'] def show_dataframe(base_dataframe): selectable_table = pn.widgets.Tabulator(base_dataframe, disabled=True, selection=[0], selectable=1, pagination='remote', page_size=20, show_index=False) row_selection = selectable_table.on_click(click) return selectable_table tabulator_data = show_dataframe(df_parameters_short) tabulator_data.servable() 

So the TIC_ID and the mode string must be updated on the input of another function. For example:

def plotter(path, TIC_ID, mode): df = pd.read_csv(path + TIC_ID + '/' + mode + '/results.csv') fig = df.hvplot.scatter(x='phase', y='flux') return fig 

I tried to set up a watcher but I couldn't get it to work, nor the depends module. I'm quite new to panels and dashboards, but I'm sure there is a simple solution to this, I just haven't found it yet.

Related questions 2 Fill pandas Panel object with data 0 Problems with in place value setting with Panel 3 Selecting rows in Pandas Panel Related questions 2 Fill pandas Panel object with data 0 Problems with in place value setting with Panel 3 Selecting rows in Pandas Panel 1 Python Panel Data 0 reading into DataFrame instead of Panel 0 Python tkinter operation for pass the value from the Textbox 0 Data selection using a button 2 Use pandas and pandastable to insert value into selected cell 1 Create panel data from a dataframe 3 How to get value from ipywidget select widget? Load 7 more related questions Show fewer related questions

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like