Python bokeh.models.widgets.Button() Examples
The following are 5
code examples of bokeh.models.widgets.Button().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bokeh.models.widgets
, or try the search function
.
Example #1
Source File: liveclient.py From backtrader_plotting with GNU General Public License v3.0 | 5 votes |
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()
Example #2
Source File: liveclient.py From backtrader_plotting with GNU General Public License v3.0 | 5 votes |
def _get_config_panel(self): def on_change_checkbox(vals): for i, f in enumerate(self._bokeh.figurepages[0].figure_envs): if i > 1: continue f.figure.visible = i in vals self._slider_aspectratio = Slider(value=self._scheme.plotaspectratio, start=0.1, end=10.0, step=0.1) button = Button(label="Save", button_type="success") button.on_click(self.on_button_save_config) r1 = row(children=[Div(text='Aspect Ratio', margin=(15, 10, 0, 10)), self._slider_aspectratio]) return Panel(child=column(children=[r1, button]), title='Config')
Example #3
Source File: layout.py From pairstrade-fyp-2019 with MIT License | 5 votes |
def build_widgets_wb(stock_list): # CODE SECTION: setup widgets, widgetbox name = controls_wb WIDGET_WIDTH = 250 # ========== Select Stocks ============= # select_stk_1 = Select(width = WIDGET_WIDTH, title='Select Stock 1:', value = stock_list[0], options=stock_list) select_stk_2 = Select(width = WIDGET_WIDTH, title='Select Stock 2:', value = stock_list[0], options=stock_list) # ========== Strategy Type ============= # strategy_list = ['kalman', 'distance', 'cointegration'] select_strategy = Select(width = WIDGET_WIDTH, title='Select Strategy:', value = strategy_list[0], options=strategy_list) # ========== set start/end date ============= # # date time variables MAX_START = date(2014, 1, 1) MAX_END = date(2018, 12, 30) DEFAULT_START = date(2016, 5, 1) DEFAULT_END = date(2016, 12, 31) STEP = 1 backtest_dates = DateRangeSlider(width = WIDGET_WIDTH, start=MAX_START, end=MAX_END, value=(DEFAULT_START, DEFAULT_END), step=STEP, title="Backtest Date Range:") start_bt = Button(label="Backtest", button_type="success", width = WIDGET_WIDTH) # controls = column(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt) controls_wb = widgetbox(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt, width=600) return controls_wb
Example #4
Source File: client_demo.py From pairstrade-fyp-2019 with MIT License | 5 votes |
def build_widgets_wb(stock_list, metrics): # CODE SECTION: setup buttons, widgetbox name = controls_wb WIDGET_WIDTH = 250 # ========== Select Stocks ============= # select_stk_1 = Select(width = WIDGET_WIDTH, title='Select Stock 1:', value = backtest_params["stk_0"], options=stock_list) select_stk_2 = Select(width = WIDGET_WIDTH, title='Select Stock 2:', value = backtest_params["stk_1"], options=stock_list) # ========== Strategy Type ============= # strategy_list = ['kalman', 'distance', 'cointegration', 'reinforcement learning'] select_strategy = Select(width = WIDGET_WIDTH, title='Select Strategy:', value = backtest_params["strategy_type"], options=strategy_list) # ========== set start/end date ============= # # date time variables MAX_START = datetime.strptime(backtest_params["max_start"], "%Y-%m-%d").date() MAX_END = datetime.strptime(backtest_params["max_end"], "%Y-%m-%d").date() DEFAULT_START = datetime.strptime(backtest_params["backtest_start"], "%Y-%m-%d").date() DEFAULT_END = datetime.strptime(backtest_params["backtest_end"], "%Y-%m-%d").date() STEP = 1 backtest_dates = DateRangeSlider(width = WIDGET_WIDTH, start=MAX_START, end=MAX_END, value=(DEFAULT_START, DEFAULT_END), step=STEP, title="Backtest Date Range:") start_bt = Button(label="Backtest", button_type="success", width = WIDGET_WIDTH) # controls = column(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt) controls_wb = widgetbox(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt, width=300) # CODE SECTION: setup table, widgetbox name = metrics_wb master_wb = None if metrics is not None: metric_source = ColumnDataSource(metrics) metric_columns = [ TableColumn(field="Metrics", title="Metrics"), TableColumn(field="Value", title="Performance"), ] metric_table = DataTable(source=metric_source, columns=metric_columns, width=300) master_wb = row(controls_wb, widgetbox(metric_table)) else: logging.info("creating controls without table") master_wb = row(controls_wb) return master_wb, select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt
Example #5
Source File: __init__.py From parambokeh with BSD 3-Clause "New" or "Revised" License | 4 votes |
def widgets(self): """Return name,widget boxes for all parameters (i.e., a property sheet)""" params = self.parameterized.params().items() key_fn = lambda x: x[1].precedence if x[1].precedence is not None else self.p.default_precedence sorted_precedence = sorted(params, key=key_fn) outputs = [k for k, p in sorted_precedence if isinstance(p, _View)] filtered = [(k,p) for (k,p) in sorted_precedence if ((p.precedence is None) or (p.precedence >= self.p.display_threshold)) and k not in outputs] groups = itertools.groupby(filtered, key=key_fn) sorted_groups = [sorted(grp) for (k,grp) in groups] ordered_params = [el[0] for group in sorted_groups for el in group] # Format name specially ordered_params.pop(ordered_params.index('name')) widgets = [Div(text='<b>{0}</b>'.format(self.parameterized.name))] def format_name(pname): p = self.parameterized.params(pname) # omit name for buttons, which already show the name on the button name = "" if issubclass(type(p),param.Action) else pname return Div(text=name) if self.p.show_labels: widgets += [self.widget(pname) for pname in ordered_params] else: widgets += [self.widget(pname) for pname in ordered_params] if self.p.button and not (self.p.callback is None and self.p.next_n==0): display_button = Button(label=self.p.button_text) def click_cb(): # Execute and clear changes since last button press try: self.execute(self._changed) except Exception as e: self._changed.clear() raise e self._changed.clear() display_button.on_click(click_cb) widgets.append(display_button) outputs = [self.widget(pname) for pname in outputs] return widgets, outputs