Hi All,
Anyone tell me how can I get widget title or name by mouse click? I want to know which widget user selected. I think the hover tool can actually display the allocated values, so I think it must be possible. But I can’ find the way I have to write.
For example , I have 3 widgets (refer below figure ) , When I click Graph1 , I want to get this title or name(‘Graph1’)
My simple code
from bokeh.models import Panel, Tabs
import panel as pn
pn.extension(sizing_mode = 'stretch_width')
from bokeh.plotting import figure
from panel.template import DarkTheme
p1 = figure(width=150, height=150, name='Scatter',title='Graph1')
p1.scatter([0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 2, 1, 0])
p2 = figure(width=150, height=150, name='Line',title='Graph2')
p2.line([0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 2, 1, 0])
p3 = figure(width=150, height=150, name='Line',title='Graph3')
p3.line([0, 1, 2, 3, 4, 5, 6], [3, 2, 1, 1, 2, 3, 4])
p4 = pn.Row(p1)+pn.Row(p2)+pn.Row(p3)
# p4 = pn.Column(p4)+pn.Column(p4)
text1 = "# Sldeber 1"
text2 = "# Sldeber 2"
text3 = "# Sldeber 3"
def side_tabs():
return pn.Tabs(
('scatter', text1),
('line', text2),
('line', text3)
)
def main_tabs():
return pn.Tabs(
('main1', p4),
('main2', p2),
('main3', p3)
)
template = pn.template.FastListTemplate(
title='contents_sample',
site='Panel',
sidebar=side_tabs(),sidebar_width =200,
main=main_tabs()
).servable();
pn.serve(template)
Someone help me my code.
Thankls,