Python bokeh.layouts.widgetbox() Examples

The following are 6 code examples of bokeh.layouts.widgetbox(). 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.layouts , or try the search function .
Example #1
Source File: file_viewer.py    From ctapipe with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_dl1_widgets(self):
        self.w_dl1_dict = dict(
            extractor=Select(
                title="Extractor:",
                value="",
                width=5,
                options=BokehFileViewer.extractor_product.values,
            ),
            extractor_window_start=TextInput(title="Window Start:", value=""),
            extractor_window_width=TextInput(title="Window Width:", value=""),
            extractor_window_shift=TextInput(title="Window Shift:", value=""),
            extractor_lwt=TextInput(title="Local Pixel Weight:", value=""),
        )

        for val in self.w_dl1_dict.values():
            val.on_change("value", self.on_dl1_widget_change)

        self.wb_extractor = widgetbox(
            PreText(text="Charge Extractor Configuration"),
            self.w_dl1_dict["extractor"],
            self.w_dl1_dict["extractor_window_start"],
            self.w_dl1_dict["extractor_window_width"],
            self.w_dl1_dict["extractor_window_shift"],
            self.w_dl1_dict["extractor_lwt"],
        ) 
Example #2
Source File: main.py    From flight_review with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def show_exception_page():
            """ show an error page in case of an unknown/unhandled exception """
            title = 'Internal Error'

            error_message = ('<h3>Internal Server Error</h3>'
                             '<p>Please open an issue on <a '
                             'href="https://github.com/PX4/flight_review/issues" target="_blank">'
                             'https://github.com/PX4/flight_review/issues</a> with a link '
                             'to this log.')
            div = Div(text=error_message, width=int(plot_width*0.9))
            plots = [widgetbox(div, width=int(plot_width*0.9))]
            curdoc().template_variables['internal_error'] = True
            return (title, error_message, plots)


        # check which plots to show 
Example #3
Source File: main.py    From bulkvis with MIT License 6 votes vote down vote up
def update():
    update_data(
        app_data['bulkfile'],
        app_data['app_vars']
    )
    if app_data['INIT']:
        build_widgets()
        layout.children[0] = widgetbox(list(app_data['wdg_dict'].values()), width=int(cfg_po['wdg_width']))
        app_data['INIT'] = False
    app_data['wdg_dict']['duration'].text = "Duration: {d} seconds".format(d=app_data['app_vars']['duration'])
    app_data['wdg_dict']['toggle_smoothing'].active = True
    layout.children[1] = create_figure(
        app_data['x_data'],
        app_data['y_data'],
        app_data['wdg_dict'],
        app_data['app_vars']
    ) 
Example #4
Source File: plotted_tables.py    From flight_review with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_logged_messages(logged_messages, plot_width):
    """
    get a bokeh widgetbox object with a table of the logged text messages
    :param logged_messages: ulog.logged_messages
    """
    log_times = []
    log_levels = []
    log_messages = []
    for m in logged_messages:
        m1, s1 = divmod(int(m.timestamp/1e6), 60)
        h1, m1 = divmod(m1, 60)
        log_times.append("{:d}:{:02d}:{:02d}".format(h1, m1, s1))
        log_levels.append(m.log_level_str())
        log_messages.append(m.message)
    log_data = dict(
        times=log_times,
        levels=log_levels,
        messages=log_messages)
    source = ColumnDataSource(log_data)
    columns = [
        TableColumn(field="times", title="Time",
                    width=int(plot_width*0.15), sortable=False),
        TableColumn(field="levels", title="Level",
                    width=int(plot_width*0.1), sortable=False),
        TableColumn(field="messages", title="Message",
                    width=int(plot_width*0.75), sortable=False),
        ]
    data_table = DataTable(source=source, columns=columns, width=plot_width,
                           height=300, sortable=False, selectable=False)
    div = Div(text="""<b>Logged Messages</b>""", width=int(plot_width/2))
    return widgetbox(div, data_table, width=plot_width) 
Example #5
Source File: layout.py    From pairstrade-fyp-2019 with MIT License 5 votes vote down vote up
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 #6
Source File: client_demo.py    From pairstrade-fyp-2019 with MIT License 5 votes vote down vote up
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