本文整理汇总了Python中bokeh.models.widgets.Tabs方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.Tabs方法的具体用法?Python widgets.Tabs怎么用?Python widgets.Tabs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models.widgets
的用法示例。
在下文中一共展示了widgets.Tabs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pad_plots
# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import Tabs [as 别名]
def pad_plots(plots):
"""
Accepts a grid of bokeh plots in form of a list of lists and
wraps any DataTable or Tabs in a WidgetBox with appropriate
padding. Required to avoid overlap in gridplot.
"""
widths = []
for row in plots:
row_widths = []
for p in row:
width = pad_width(p)
row_widths.append(width)
widths.append(row_widths)
plots = [[WidgetBox(p, width=w) if isinstance(p, (DataTable, Tabs)) else p
for p, w in zip(row, ws)] for row, ws in zip(plots, widths)]
return plots
示例2: generate_model
# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import Tabs [as 别名]
def generate_model(self, figurepage_idx: int = 0) -> Model:
"""Returns a model generated from internal blueprints"""
if figurepage_idx >= len(self.figurepages):
raise RuntimeError(f'Cannot generate model for FigurePage with index {figurepage_idx} as there are only {len(self.figurepages)}.')
figurepage = self.figurepages[figurepage_idx]
if not self._is_optreturn:
tabs = self.generate_model_tabs(figurepage)
else:
tabs = []
# now append analyzer tab(s)
analyzers = figurepage.analyzers
panel_analyzer = self.get_analyzer_panel(analyzers)
if panel_analyzer is not None:
tabs.append(panel_analyzer)
# append meta tab
if not self._is_optreturn:
assert figurepage.strategy is not None
meta = Div(text=metadata.get_metadata_div(figurepage.strategy))
metapanel = Panel(child=meta, title="Meta")
tabs.append(metapanel)
model = Tabs(tabs=tabs)
# attach the model to the underlying figure for later reference (e.g. unit test)
figurepage.model = model
return model
示例3: __init__
# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import Tabs [as 别名]
def __init__(self, doc: Document, push_fnc, bokeh_fac: callable, push_data_fnc:callable, strategy: bt.Strategy, figurepage_idx: int = 0, lookback: int = 20):
self._slider_aspectratio = None
self._push_data_fnc = push_data_fnc
self._push_fnc = push_fnc
self._figurepage_idx = figurepage_idx
self.last_data_index = -1
self._lookback = lookback
self._strategy = strategy
self._current_group = None
self.document = doc
self._bokeh_fac = bokeh_fac
self._bokeh = None
bokeh = self._bokeh_fac() # temporary bokeh object to get tradingdomains and scheme
self._scheme = copy(bokeh.p.scheme) # preserve original scheme as originally provided by the user
tradingdomains = bokeh.list_tradingdomains(strategy)
self._current_group = tradingdomains[0]
self._select_tradingdomain = Select(value=self._current_group, options=tradingdomains)
self._select_tradingdomain.on_change('value', self._on_select_group)
btn_refresh_analyzers = Button(label='Refresh Analyzers', width=100)
btn_refresh_analyzers.on_click(self._on_click_refresh_analyzers)
td_label = Div(text="Trading Domain:", margin=(9, 5, 15, 5))
controls = row(children=[td_label, self._select_tradingdomain, btn_refresh_analyzers])
self.model = column(children=[controls, Tabs(tabs=[])], sizing_mode=self._scheme.plot_sizing_mode)
# append meta tab
meta = Div(text=metadata.get_metadata_div(strategy))
self._panel_metadata = Panel(child=meta, title="Meta")
self._refreshmodel()
示例4: compute_plot_size
# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import Tabs [as 别名]
def compute_plot_size(plot):
"""
Computes the size of bokeh models that make up a layout such as
figures, rows, columns, widgetboxes and Plot.
"""
if isinstance(plot, GridBox):
ndmapping = NdMapping({(x, y): fig for fig, y, x in plot.children}, kdims=['x', 'y'])
cols = ndmapping.groupby('x')
rows = ndmapping.groupby('y')
width = sum([max([compute_plot_size(f)[0] for f in col]) for col in cols])
height = sum([max([compute_plot_size(f)[1] for f in row]) for row in rows])
return width, height
elif isinstance(plot, (Div, ToolbarBox)):
# Cannot compute size for Div or ToolbarBox
return 0, 0
elif isinstance(plot, (Row, Column, WidgetBox, Tabs)):
if not plot.children: return 0, 0
if isinstance(plot, Row) or (isinstance(plot, ToolbarBox) and plot.toolbar_location not in ['right', 'left']):
w_agg, h_agg = (np.sum, np.max)
elif isinstance(plot, Tabs):
w_agg, h_agg = (np.max, np.max)
else:
w_agg, h_agg = (np.max, np.sum)
widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
return w_agg(widths), h_agg(heights)
elif isinstance(plot, (Figure, Chart)):
if plot.plot_width:
width = plot.plot_width
else:
width = plot.frame_width + plot.min_border_right + plot.min_border_left
if plot.plot_height:
height = plot.plot_height
else:
height = plot.frame_height + plot.min_border_bottom + plot.min_border_top
return width, height
elif isinstance(plot, (Plot, DataTable, Spacer)):
return plot.width, plot.height
else:
return 0, 0
示例5: pad_width
# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import Tabs [as 别名]
def pad_width(model, table_padding=0.85, tabs_padding=1.2):
"""
Computes the width of a model and sets up appropriate padding
for Tabs and DataTable types.
"""
if isinstance(model, Row):
vals = [pad_width(child) for child in model.children]
width = np.max([v for v in vals if v is not None])
elif isinstance(model, Column):
vals = [pad_width(child) for child in model.children]
width = np.sum([v for v in vals if v is not None])
elif isinstance(model, Tabs):
vals = [pad_width(t) for t in model.tabs]
width = np.max([v for v in vals if v is not None])
for model in model.tabs:
model.width = width
width = int(tabs_padding*width)
elif isinstance(model, DataTable):
width = model.width
model.width = int(table_padding*width)
elif isinstance(model, (WidgetBox, Div)):
width = model.width
elif model:
width = model.plot_width
else:
width = 0
return width
示例6: plot_hail_hist_both
# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import Tabs [as 别名]
def plot_hail_hist_both(
hist_data: hl.Struct, title: str, normalize: bool = True, log: bool = False
):
p1 = plot_hail_hist(hist_data, title, log)
p2 = plot_hail_hist_cumulative(
hist_data, f"{title} (Cumulative)", normalize, log=log
)
return Tabs(
tabs=[Panel(child=p1, title="Raw"), Panel(child=p2, title="Cumulative")]
)
示例7: linear_and_log_tabs
# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import Tabs [as 别名]
def linear_and_log_tabs(plot_func: Callable, **kwargs) -> Tabs:
panels = []
for axis_type in ["linear", "log"]:
fig = plot_func(**kwargs, axis_type=axis_type)
panel = Panel(child=fig, title=axis_type)
panels.append(panel)
return Tabs(tabs=panels)