import pandas as pd
import panel as pn
raw_data = \
[
{
"value": 'A',
"frequency": 3
},
{
"value": 'B',
"frequency": 2
},
{
"value": 'C',
"frequency": 1
},
{
"value": 'D',
"frequency": 1
},
{
"value": 'E',
"frequency": 1
},
{
"value": 'F',
"frequency": 2
},
]
def contextMenu():
print("Selected Option One from context menu...")
value_freq = pd.DataFrame(raw_data)
tabWid = pn.widgets.Tabulator(value_freq, configuration={
'rowContextMenu':[
{
'label':'Option One',
'action':contextMenu()
},
{
'separator':True
},
]
})
pn.Row(tabWid).servable()
It is observed that the context menu appears on right click but the function is not called.
contextMenu() function is called at the very beginning for only once during initialization phase.
It would also be great if I get the cell value from where the context menu is used
for eg: If context menu is used from cell with value āCā then how do I get the value āCāā¦??
(I know I can make use of selection feature to trigger a function whenever a cell is selected, but would like to know how context_menu can be implemented)
Thanks in advance.