示例#1
0
    def action_button(self):
        if self.disable_validation or self.validated:
            button = 'submit_btn'
            button_type = 'success'
        else:
            button = 'validate_btn'
            button_type = 'primary'

        action_btn = pn.Param(
            self.param[button],
            widgets={button: {
                'button_type': button_type,
                'width': 200
            }})[0]
        cancel_btn = pn.Param(
            self.param.cancel_btn,
            widgets={'cancel_btn': {
                'button_type': 'danger',
                'width': 200
            }})[0]

        spn = pn.widgets.indicators.LoadingSpinner(value=True,
                                                   color='primary',
                                                   aspect_ratio=1,
                                                   width=0)

        args = {'action_btn': action_btn, 'cancel_btn': cancel_btn, 'spn': spn}
        code = 'action_btn.visible=false; cancel_btn.visible=false; spn.width=50;'
        action_btn.js_on_click(args=args, code=code)
        cancel_btn.js_on_click(args=args, code=code)

        return pn.Row(action_btn, cancel_btn, spn)
示例#2
0
 def panel(self):
     layout = pn.Card(sizing_mode='stretch_width',
                      title="Parametres",
                      collapsed=True)
     layout.append(
         pn.Param(
             self.param,
             widgets={
                 # 'logo': pn.widgets.FileInput(accept='.jpg,.png,.ico,.gif',name="Logo"),
                 'specfile':
                 pn.widgets.FileInput(accept='.yaml,.yml',
                                      name="Specification File")
             },
             show_name=False,
             expand_button=False,
             expand=False,
             sizing_mode="stretch_width"), )
     if self.config:
         layout.append(
             pn.Param(
                 self.config.param,
                 show_name=False,
                 expand_button=False,
                 expand=False,
                 sizing_mode="stretch_width",
             ))
     return layout
示例#3
0
文件: stages.py 项目: yougis/sudBoard
    def panel(self):
        layout = pn.Row(
            pn.Column(pn.Param(
                self.param,
                parameters=['viewTypeSelector'],
                widgets={'viewTypeSelector': pn.widgets.RadioButtonGroup},
                expand_button=False,
                expand=False,
                sizing_mode='stretch_width',
                show_name=False),
                      self.view,
                      self.dashviz,
                      css_classes=['panel-widget-box'],
                      sizing_mode='stretch_width'),
            pn.Column(pn.Param(
                self.param,
                parameters=['filterTypeSelector'],
                widgets={'filterTypeSelector': pn.widgets.RadioButtonGroup},
                expand_button=False,
                expand=False,
                sizing_mode='stretch_width',
                show_name=False),
                      self.filter,
                      css_classes=['panel-widget-box'],
                      sizing_mode='stretch_width'),
        )

        return layout
示例#4
0
    def __init__(self, **params):
        super(AsyncApp, self).__init__(**params)

        self.view = pn.Column(
            pn.pane.Markdown(__doc__),
            pn.layout.Divider(),
            pn.pane.Markdown("## Starts async background tasks"),
            pn.Param(
                self,
                parameters=["do_stuff", "result"],
                widgets={
                    "result": {
                        "disabled": True
                    },
                    "do_stuff": {
                        "button_type": "success"
                    }
                },
                show_name=False,
            ),
            progress.view,
            pn.layout.Divider(),
            pn.pane.Markdown("## Works while background tasks are running"),
            pn.Param(
                self,
                parameters=["select", "slider", "text"],
                widgets={"text": {
                    "disabled": True
                }},
                show_name=False,
            ),
            max_width=500,
        )
示例#5
0
def section(component, message=None, show_html=False):
    """Helper function. Turns the component into a tuple of components containing

    - Title
    - Description
    - The Component
    - A Param of the Component parameters
    - A Divider
    """
    title = "## " + str(type(component)).split(".")[4][:-2]

    parameterset = set(component._child_parameters())  # pylint: disable=protected-access
    if show_html:
        parameterset.add("html")
    for parameter in component.parameters_to_watch:
        parameterset.add(parameter)

    parameters = list(parameterset)
    if message:
        return (
            pn.pane.Markdown(title),
            component,
            pn.Param(component, parameters=parameters),
            pn.pane.Markdown(message),
            pn.layout.Divider(),
        )
    return (
        pn.pane.Markdown(title),
        component,
        pn.Param(component, parameters=parameters),
        pn.layout.Divider(),
    )
 def _param_view(
     self,
 ):
     if self.period_type == "Period":
         return pn.Param(
             self,
             parameters=[
                 "period_type",
                 "interval",
                 "period",
             ],
             default_layout=GridBoxWithTwoColumns,
             width=400,
             show_name=False,
         )
     return pn.Param(
         self,
         parameters=[
             "period_type",
             "interval",
             "start",
             "end",
         ],
         default_layout=GridBoxWithTwoColumns,
         widgets={
             "start": pn.widgets.DatePicker,
             "end": pn.widgets.DatePicker,
         },
         width=600,
         show_name=False,
     )
示例#7
0
    def __init__(self, **params):
        super().__init__(**params)

        pn.config.sizing_mode = "stretch_width"

        app = pn.Column(
            pn.pane.Markdown("## Background Task"),
            pn.Param(
                self,
                parameters=["do_stuff", "result"],
                widgets={"result": {"disabled": True}, "do_stuff": {"button_type": "primary"}},
                show_name=False,
            ),
            progress.view,
            pn.pane.Markdown("## Other Tasks"),
            pn.Param(
                self,
                parameters=["select", "slider", "text"],
                widgets={"text": {"disabled": True}},
                show_name=False,
            ),
        )
        main = [APPLICATION.intro_section(), app]

        self.view = site.create_template(
            main=main,
            main_max_width="700px",
        )
示例#8
0
文件: utils.py 项目: erdc/pyuit
    def panel(self):
        log_content = pn.pane.Str(self.log_content, sizing_mode='stretch_both')

        refresh_btn = pn.widgets.Button.from_param(self.param.refresh_btn,
                                                   button_type='primary',
                                                   width=100)
        args = {'log': log_content, 'btn': refresh_btn}
        code = 'btn.css_classes.push("pn-loading", "arcs"); btn.properties.css_classes.change.emit(); ' \
               'log.css_classes.push("pn-loading", "arcs"); log.properties.css_classes.change.emit();'
        refresh_btn.js_on_click(args=args, code=code)

        if self.is_array:
            sub_job_selector = pn.Param(self.parent.param.selected_sub_job)[0]
            sub_job_selector.width = 300
            sub_job_selector.jscallback(args=args, value=code)
        else:
            sub_job_selector = None

        log_type_selector = pn.Param(self.param.log)[0]
        log_type_selector.width = 300
        log_type_selector.jscallback(args, value=code)

        return pn.Column(sub_job_selector,
                         log_type_selector,
                         refresh_btn,
                         log_content,
                         sizing_mode='stretch_both')
    def _get_view_objects(self):
        load_default_page_pane = pn.Param(
            self.page_service,
            parameters=["load_default_page"],
            widgets={
                "load_default_page": {"type": pn.widgets.Button, "name": self.application.title}
            },
            show_name=False,
            show_labels=False,
            sizing_mode="stretch_width",
        )
        seperator_pane = pn.pane.Markdown("/", sizing_mode="fixed", width=5)

        page_pane = pn.Param(
            self.page_service,
            parameters=["page"],
            expand_button=False,
            show_name=False,
            show_labels=False,
            sizing_mode="stretch_width",
        )

        return [
            load_default_page_pane,
            seperator_pane,
            page_pane,
        ]
示例#10
0
 def panel(self):
     self.available_attributes()  # for the initial load
     return pn.Column(
         pn.Row(pn.Param(self.load_sim_widget, show_name=False),
                pn.Param(self.att_widget, show_name=False),
                pn.Param(self.projection, show_name=False),
                name=self.label),
         pn.Pane(self.param, parameters=['load_data'], show_name=False))
 def widgets(self):
     if self.source != "check_one_room":
         return pn.Param(self.param,
                         name=self.source.replace('_', ' '),
                         parameters=['table_selector', 'y_selec'],
                         height_policy='fit',
                         width_policy='fit')
     else:
         return pn.Param(self.param,
                         name=self.source.replace('_', ' '),
                         parameters=['table_selector2', 'y_selec2'],
                         height_policy='fit',
                         width_policy='fit')
示例#12
0
    def __init__(self, **params):
        super().__init__(**params)

        self.start_loading = self._start_loading
        self.stop_loading = self._stop_loading

        self.update_plot = self._update_plot

        hv_plot = self._get_plot()
        self.hv_plot_panel = pn.pane.HoloViews(hv_plot,
                                               min_height=300,
                                               sizing_mode="stretch_both")
        self.styler = LoadingStyler(name="Styles")

        self.panels = [
            pn.Param(
                self.param.update_plot,
                widgets={"update_plot": {
                    "button_type": "primary"
                }},
            ),
            self.hv_plot_panel,
        ]

        self.settings_panel = pn.Column(
            pn.pane.Markdown("## Settings"),
            pn.Param(
                self,
                parameters=[
                    "start_loading",
                    "stop_loading",
                    "sleep",
                    "show_shared_spinner",
                ],
                widgets={
                    "style": {
                        "type": pn.widgets.TextAreaInput,
                        "sizing_mode": "stretch_width",
                        "height": 100,
                        "disabled": True,
                    }
                },
                show_name=False,
            ),
            self.styler.settings_panel,
            sizing_mode="stretch_width",
        )
        self.main = pn.Column(*self.panels,
                              self.styler.style_panel,
                              sizing_mode="stretch_both")
        self.view = pn.Row(self.settings_panel, self.main)
    def _create_designer_pane(  # pylint: disable=too-many-arguments
        self,
        title_component,
        action_pane,
        settings_scroll_pane,
        stop_server_pane,
        font_pane,
        css_pane,
        js_pane,
    ):

        return pn.Column(
            title_component.view,
            pn.layout.Divider(margin=(10, 5, 5, 10)),
            pn.Param(
                self,
                parameters=["component_reloader"],
                show_name=False,
                expand_button=False,
                sizing_mode="stretch_width",
            ),
            action_pane,
            pn.layout.Divider(margin=(10, 5, 5, 10)),
            settings_scroll_pane,
            pn.layout.Divider(margin=(10, 5, 5, 10)),
            stop_server_pane,
            font_pane,
            css_pane,
            js_pane,
            name="Designer Pane",
            sizing_mode="stretch_width",
            background="#F5F5F5",
            margin=(0, 0, 0, 0),
            css_classes=["designer-design-pane"],
        )
示例#14
0
 def make_panel(self):
     header = pn.Column(
         pn.layout.Divider(),
         f"### {self.name}",
         width_policy='max',
         sizing_mode=self.sizing_mode,
         width=self.max_width,
     )
     
     # buttons = pn.Row(param_buttons, self.delete_button)
 
     editors = pn.Param(self.param,
                        show_name=False,
                        default_layout=DefaultLayout,
                        widgets=self._widgets,
                        parameters=list(self.schema)+settings.META_FIELDS,
                        width_policy='max',
                        sizing_mode=self.sizing_mode,
                        width=self.max_width,
                        )
     # media_previews = 
     return pn.Column(header,
                     editors,
                     self.buttons,
                     width_policy='max',
                     sizing_mode=self.sizing_mode,
                     width=self.max_width,
                     )
示例#15
0
 def panel(self, cross_selector=False):
     if cross_selector:
         return pn.Row(
             self.view,
             pn.Param(self.param, widgets={'y': pn.widgets.CrossSelector}))
     else:
         return pn.Row(self.param, self.view)
示例#16
0
 def make_panel(self):
     return pn.Param(self.param,
                     max_width=self.max_width,
                     max_height=self.max_height,
                     sizing_mode=self.sizing_mode,
                     parameters=["username", "password"],
                     widgets={"password": pn.widgets.PasswordInput})
示例#17
0
 def render(self):
     return pn.Column(
         pn.pane.Markdown(
             '### Start annotating by double clicking into the plot. This will mark the start of a range. Double click again to mark the end of the range.',
             style={
                 'font-family': "serif",
                 'color': "#ff0000"
             }),
         pn.Row(
             pn.pane.Markdown('### Classification for next annotation:',
                              style={'font-family': "serif"}),
             pn.Param(
                 self.param.next_classification,
                 widgets={
                     "next_classification":
                     pn.widgets.RadioButtonGroup(
                         options=CLASSIFICATIONS,
                     )  #style={'font-size':'10pt'},css_classes=["widget-button"])
                 }),
             pn.Spacer(background='white', width=100, height=10),
             #self.param.remove_last_annotation,
             self.param.save_annotations,
         ),
         *(self.plot()),
         pn.pane.Markdown(
             f"### List of annotations for mission {self.mission_id}",
             style={'font-family': "serif"}),
         self.plot_annotation_details,
     )
示例#18
0
文件: stages.py 项目: yougis/sudBoard
    def panel(self):

        redirect = f""" window.location.href="{self.url}"
        """

        boutonSave = pn.widgets.Button(name=self.param.boutonSave.label,
                                       button_type="success")
        boutonFinish = pn.widgets.Button(name=self.param.boutonFinish.label,
                                         button_type="primary")

        boutonFinish.js_on_click(code=redirect)

        return pn.Column(pn.Param(
            self.param,
            parameters=[
                'targetName', 'toExistingTarget', 'boutonSave', 'boutonFinish'
            ],
            widgets={
                "toExistingTarget":
                pn.widgets.button.Toggle(
                    name="Intégrer la représentation à un moniteur existant"),
                "boutonSave":
                boutonSave,
                "boutonFinish":
                boutonFinish
            },
            show_name=False,
            expand_button=False,
            expand=False,
            sizing_mode='stretch_width'),
                         self.view,
                         self.html_pane,
                         css_classes=['panel-widget-box'],
                         sizing_mode='stretch_width')
示例#19
0
def _chart_app(chart):
    return pn.Row(
        pn.WidgetBox(
            pn.Param(
                chart,
                parameters=[
                    "height",
                    "width",
                    "sizing_mode",
                    "margin",
                    "object",
                    "object_update",
                    "event",
                ],
                widgets={
                    "object": pn.widgets.LiteralInput,
                    "object_update": pn.widgets.LiteralInput,
                    "event": pn.widgets.StaticText,
                },
            ),
            sizing_mode="fixed",
        ),
        chart,
        sizing_mode="stretch_both",
    )
示例#20
0
def _fast_button_card():
    button = pn.widgets.Button(name="Click me", button_type="primary")
    button.param.name.precedence = 0
    button.param.clicks.precedence = 0
    button.param.disabled.precedence = 0
    button.param.button_type.precedence = 0
    button_parameters = [
        "name",
        "button_type",
        "clicks",
        "disabled",
        "width",
        "height",
        "sizing_mode",
    ]
    settings = pn.Param(
        button,
        parameters=button_parameters,
        show_name=False,
        sizing_mode="stretch_width",
    )
    return pn.Column(
        pn.pane.HTML("<h2>Button</h2>"),
        button,
        pn.pane.HTML("<h3>Parameters</h3>"),
        settings,
        sizing_mode="stretch_both",
    )
示例#21
0
 def view(
     self,
 ):
     """A Reactive View of the KickstarterDashboard"""
     return pn.Column(
         pn.pane.Markdown(__doc__),
         pn.layout.HSpacer(height=25),
         pn.Row(
             pn.Column(self.scatter_plot_view, self.bar_chart_view, sizing_mode="stretch_width"),
             pn.Param(
                 self.param.categories,
                 widgets={
                     "categories": {
                         "max_width": 125,
                         "size": len(self.categories),
                     }
                 },
                 width=150,
                 height=500,
                 sizing_mode="fixed",
             ),
             sizing_mode="stretch_width",
         ),
         sizing_mode="stretch_width",
     )
示例#22
0
    def section(component, message=None):
        title = "## " + str(type(component)).split(".")[-1][:-2]

        parameters = [
            "value",
            "columns",
            # "parsed_computed_columns",
            "computed_columns",
            "column_pivots",
            "row_pivots",
            "aggregates",
            "sort",
            "filters",
            "plugin",
            "theme",
        ]

        if message:
            return (
                pn.pane.Markdown(title),
                component,
                pn.Param(component, parameters=parameters),
                pn.pane.Markdown(message),
                pn.layout.Divider(),
            )
        return (
            pn.pane.Markdown(title),
            component,
            pn.Row(stream_button, patch_button, reset_button),
            # pn.Param(component, parameters=parameters),
            pn.layout.Divider(),
        )
示例#23
0
 def panel(self):
     return pn.Param(self.param, show_name=False, sizing_mode='stretch_width', widgets={
         'command_output': dict(
             type=AnsiColorText,
             sizing_mode='stretch_width',
             height=800)
     })
    def __init__(self, **params):
        super().__init__(**params)

        self.scatter_panel = pn.pane.HoloViews(sizing_mode="stretch_both")
        self.hist_panel = pn.pane.HoloViews(sizing_mode="stretch_both")
        self.reset_plots = self._update_plot_panels

        self.settings_panel = pn.Param(
            self,
            parameters=["backend", "reset_plots"],
            widgets={
                "backend": {
                    "type": pn.widgets.RadioButtonGroup,
                    "button_type": "success"
                },
                "reset_plots": {
                    "type": pn.widgets.Button,
                    "button_type": "default"
                },
            },
            show_name=False,
        )
        self.view = self._create_view()

        pn.state.onload(self._update_plot_panels)
示例#25
0
 def _get_view(self):
     """Returns the application view"""
     pn.config.sizing_mode = "stretch_width"
     intro_section = APPLICATION.intro_section()
     main = [
         intro_section,
         pn.Column(
             pn.pane.Markdown("#### Settings"),
             pn.Param(
                 self,
                 parameters=["load_time", "update_action"],
                 show_name=False,
                 sizing_mode="stretch_width",
                 widgets={"update_action": {
                     "button_type": "primary"
                 }},
             ),
             pn.pane.Markdown("#### Progress"),
             self.progress_widget,
             pn.pane.Markdown("#### Plot"),
             self.plot_pane,
         ),
     ]
     template = site.create_template(title="Data Explorer Loading",
                                     main=main)
     self.plot_pane.theme = template.theme.bokeh_theme
     return template
def get_tqdm_app():
    import time
    import pandas as pd
    import numpy as np

    tqdm = Tqdm(layout="row", sizing_mode="stretch_width")

    def run(*events):
        for index in tqdm(range(0, 10)):
            time.sleep(0.2)

    button = pn.widgets.Button(name="Run Loop", button_type="primary")
    button.on_click(run)

    # Register Pandas. This gives DataFrame.progress_apply method
    tqdm.tqdm.pandas(desc="my bar!")

    df = pd.DataFrame(np.random.randint(0, 100, (100000, 6)))

    def run_df(*events):
        df.progress_apply(lambda x: x ** 2)

    pandas_button = pn.widgets.Button(name="Pandas Apply", button_type="success")
    pandas_button.on_click(run_df)
    pandas_button

    component = pn.Column(button, pandas_button, tqdm, sizing_mode="stretch_width")
    template = pn.template.FastListTemplate(
        title="Panel - Tqdm Indicator",
        main=[component],
        sidebar=[
            pn.Param(tqdm, sizing_mode="stretch_width"),
        ],
    )
    return template
示例#27
0
 def credentials_view(self):
     init_flow_button = pn.widgets.Button(name="Generate",
                                          button_type="primary",
                                          width=70)
     init_flow_button.on_click(lambda event: self.initiate_flow())
     params = pn.Param(self.param,
                       parameters=[
                           "token", "auth_server_uri", "client_id",
                           "notify_email"
                       ],
                       widgets={
                           "token": {
                               "type": pn.widgets.TextAreaInput,
                               "width": 300
                           }
                       },
                       max_width=300,
                       sizing_mode="stretch_width")
     buttons = pn.Row(init_flow_button)
     if self._cb is not None:
         buttons.append(self.authorize_link())
         buttons.append(
             pn.indicators.LoadingSpinner(value=True, width=20, height=20))
     return pn.Column(params,
                      buttons,
                      sizing_mode="stretch_width",
                      width=300)
示例#28
0
 def _get_view(self):
     """Returns the application view"""
     pn.config.sizing_mode = "stretch_width"
     template = pn.template.FastListTemplate(title="Data Explorer Loading")
     self.plot_pane = pn.pane.HoloViews(EMPTY_PLOT,
                                        sizing_mode="stretch_both",
                                        min_height=300)
     self.progress_widget = pn.widgets.Progress(name="Progress",
                                                sizing_mode="stretch_width",
                                                value=1,
                                                max=100000)
     intro_section = APPLICATION.intro_section()
     template.main[:] = [
         intro_section,
         pn.Column(
             pn.pane.Markdown("#### Settings"),
             pn.Param(
                 self,
                 parameters=["load_time", "update_action"],
                 show_name=False,
                 sizing_mode="stretch_width",
                 widgets={"update_action": {
                     "button_type": "primary"
                 }},
             ),
             pn.pane.Markdown("#### Progress"),
             self.progress_widget,
             pn.pane.Markdown("#### Plot"),
             self.plot_pane,
         ),
     ]
     return template
示例#29
0
    def __init__(self, **params):
        super().__init__(**params)

        self.settings_panel = pn.Param(
            self,
            parameters=[
                "spinner",
                "spinner_height",
                "background_alpha",
                "color",
                "style",
            ],
            widgets={
                "style": {
                    "type": pn.widgets.TextAreaInput,
                    "sizing_mode": "stretch_both",
                    "disabled": True,
                }
            },
        )

        self.style_panel = pn.pane.HTML(sizing_mode="fixed",
                                        width=0,
                                        height=0,
                                        margin=0)
        self._toggle_color()
        self._update_style()
示例#30
0
 def profile_management_panel(self):
     return pn.Row(
         pn.Column(
             pn.Param(
                 self,
                 parameters=[
                     'version', 'environment_profile_version',
                     'set_default_btn'
                 ],
                 widgets={
                     'set_default_btn': {
                         'button_type': 'primary',
                         'width': 200,
                         'margin': (23, 0, 0, 0)
                     },
                     'version': {
                         'width': 200
                     },
                     'environment_profile_version':
                     pn.widgets.RadioBoxGroup,
                 },
                 show_name=False,
             ),
             self.no_version_profiles_alert,
         ),
         self.delete_panel,
     )