def layout_element_widgets(self):
     """Add header line on top of element widgets container"""
     colors = config.app.style.colors
     quality_colors = pn.Row(
         pn.layout.HSpacer(),
         pn.pane.HTML(background=colors.poor, width=40, height=20),
         pn.layout.HSpacer(),
         pn.layout.Spacer(width=4),  # Tweak to improve alignment
         pn.pane.HTML(background=colors.moderate, width=40, height=20),
         pn.layout.Spacer(width=4),  # Tweak to improve alignment
         pn.layout.HSpacer(),
         pn.pane.HTML(background=colors.good, width=40, height=20),
         pn.layout.HSpacer(),
         pn.layout.Spacer(width=5),  # Tweak to improve alignment
         pn.pane.HTML(background=colors.exceptional, width=40, height=20),
         pn.layout.Spacer(width=5),  # Tweak to improve alignment
         pn.layout.HSpacer(),
     )
     return pn.GridBox(
         "**Element**",
         "",
         pn.Row(pn.layout.Spacer(width=10), "**Volume %**"),
         quality_colors,
         ncols=4,
     )
Пример #2
0
    def _get_gridbox(self, what):
        """Return GridBox with matplotlib for GS/DFPT SCF cycles."""
        if what == "GS":
            cycles = self.outfile.get_all_gs_scf_cycles()
        elif what == "DFPT":
            cycles = self.outfile.get_all_d2de_scf_cycles()
        else:
            raise ValueError("Invalid value for what: %s" % what)

        if not cycles: return None

        num_plots, nrows, ncols = len(cycles), 1, 1
        if num_plots > 1:
            ncols = 2
            nrows = (num_plots // ncols) + (num_plots % ncols)

        box = pn.GridBox(nrows=nrows,
                         ncols=ncols)  #, sizing_mode='scale_both')
        for icycle, cycle in enumerate(cycles):
            box.append(
                self._mp(
                    cycle.plot(title="%s cycle #%d" % (what, icycle),
                               **self.fig_kwargs)))

        return box
Пример #3
0
    def plot_annotation_details(self):

        elements = []
        for i, (ix, r) in enumerate(
                self.annotations
                # Sorting the dataframe here is necessary,
                # otherwise we would number the ranges by their insertion, not by their time.
                .sort_values("start_clock_ms").iterrows()):
            if str(r["mission_id"]) == str(self.mission_id):
                select = pn.widgets.RadioButtonGroup(
                    name="Select classification",
                    options=CLASSIFICATIONS,
                    value=r["classification"],
                    inline=True,
                )

                remove = pn.widgets.Button(
                    name="remove",
                    width=40,
                )
                clock_ms = int(float(r['start_clock_ms']) / 1000)
                tstamp = datetime.fromtimestamp(clock_ms).strftime("%H:%M:%S")
                select.param.watch(
                    partial(
                        lambda ix, event: self.on_change_annotation(
                            ix, event.new), ix), "value")
                remove.param.watch(
                    partial(lambda ix, event: self.on_remove_annotation(ix),
                            ix), "clicks")
                elements.extend([
                    pn.widgets.StaticText(name=f"@ {tstamp} ", value=""),
                    remove, select
                ])
        return pn.GridBox(*elements, ncols=3, width=1200)
Пример #4
0
def get_tmpl():
  tmpl = pn.template.VanillaTemplate(title='Icon Menu')

  dd0  = DragMenu(pn.WidgetBox(pn.pane.Markdown('# H1aaaa'),
                                  pn.widgets.FloatSlider(value=2,end=10)))
  dd1 = DragMenu(pn.WidgetBox(pn.pane.Markdown('# H2aaaa'),
                                  pn.widgets.FloatSlider(value=2,end=10),
        pn.pane.PNG('https://holoviz.org/assets/earthquakes.png', width= 500, height=300)
        ), icon='bicycle')

  grid = pn.GridBox('', 'light', 'dark', ncols=3)

  for color in pn.indicators.LoadingSpinner.param.color.objects:
      dark = pn.indicators.LoadingSpinner(width=50, height=50, value=True, color=color, bgcolor='dark')
      light = pn.indicators.LoadingSpinner(width=50, height=50, value=True, color=color, bgcolor='light')
      grid.extend((color, light, dark))


  xs = np.linspace(0, np.pi)
  freq = pn.widgets.FloatSlider(name="Frequency", start=0, end=10, value=2)
  phase = pn.widgets.FloatSlider(name="Phase", start=0, end=np.pi)

  @pn.depends(freq=freq, phase=phase)
  def sine(freq, phase):
      return hv.Curve((xs, np.sin(xs*freq+phase))).opts(
          responsive=True, min_height=500)

  @pn.depends(freq=freq, phase=phase)
  def cosine(freq, phase):
      return hv.Curve((xs, np.cos(xs*freq+phase))).opts(
          responsive=True, min_height=500)

  dd2 = DragMenu(pn.WidgetBox(grid))

  dd3 = DragMenu(pn.WidgetBox('# Trig control', freq, phase))

  row = pn.Row(pn.Spacer(sizing_mode='stretch_width'),
              dd0, dd1, dd2, dd3,
              margin=(0,0,0,0),
              sizing_mode='stretch_width')

  tmpl.header.append(row)

  tmpl.main.append(pn.Row(cosine,sizing_mode='stretch_both'))


  return tmpl
Пример #5
0
    def _set_up_panel(self, size=200):
        init_sample_indices = np.random.choice(
            np.arange(len(self.df))[pd.isna(self.df[self.categories[0]])], 9)
        self._current_indices = init_sample_indices
        self._taggers = [
            SingleImageTagger(self.df.loc[i, "filepath"], self.categories[0],
                              size) for i in init_sample_indices
        ]
        self._grid = pn.GridBox(*[t.panel for t in self._taggers],
                                ncols=3,
                                nrows=3,
                                width=3 * size)
        self._classchooser = pn.widgets.Select(options=self.categories,
                                               value=self.categories[0],
                                               name="Class to annotate",
                                               width=size)
        self._selectchooser = pn.widgets.Select(
            options=["all", "partially labeled"],
            value="all",
            name="Sample from",
            width=size)

        self._samplesavebutton = pn.widgets.Button(name="save and sample",
                                                   button_type="primary",
                                                   width=size)
        self._samplebutton = pn.widgets.Button(name="sample without saving",
                                               button_type="danger",
                                               width=size)
        self._summaries = pn.pane.DataFrame(self._compute_summaries(),
                                            index=False,
                                            width=size)
        self.panel = pn.Row(
            self._grid, pn.Spacer(width=50),
            pn.Column(self._classchooser, self._selectchooser,
                      self._samplesavebutton, self._samplebutton,
                      self._summaries))
        # set up button callbacks
        self._samplebutton.on_click(self._sample)
        self._samplesavebutton.on_click(self._record_and_sample_callback)
Пример #6
0
debug_text = pn.widgets.StaticText(value="")

width_entry = pn.widgets.IntInput(name="Plot width",
                                  start=300,
                                  end=1200,
                                  step=50,
                                  value=600)
ncols_entry = pn.widgets.IntInput(name="n_cols",
                                  start=1,
                                  end=4,
                                  step=1,
                                  value=2)
# width_slider = pn.widgets.IntSlider(name='Plot width', start=400, end=1200, step=50, value=600)
# ncols_slider = pn.widgets.IntSlider(name='Number of columns', start=1, end=4, step=1, value=2)

plots = pn.GridBox(["Plots will show up here when selected."], ncols=2)
plots2 = pn.GridBox([], ncols=2)


def update_butler(event):
    global config
    global butler
    global registry

    try:
        butler = dafButler.Butler(config=repo_config_string)
        registry = butler.registry
        collections = list(registry.queryCollections())
        collection_select.options = collections
        collection_select.value = collections[0]
Пример #7
0
icon_numbers  = pn.pane.HTML('')


df = pd.DataFrame({
    'int': [1, 2, 3],
    'float': [3.14, 6.28, 9.42],
    'str': ['A', 'B', 'C'],
    'bool': [True, False, True],
    'date': [date(2019, 1, 1), date(2020, 1, 1),date(2020, 1, 10)]
}, index=[1, 2, 3])

df_widget = pn.widgets.Tabulator(df)


grid = pn.GridBox('', 'light', 'dark', ncols=3)

for color in pn.indicators.LoadingSpinner.param.color.objects:
    dark = pn.indicators.LoadingSpinner(width=50, height=50, value=True, color=color, bgcolor='dark')
    light = pn.indicators.LoadingSpinner(width=50, height=50, value=True, color=color, bgcolor='light')
    grid.extend((color, light, dark))

sli = pn.widgets.IntSlider(name='counting',value=0,end=100)

tm = (19,9,0,0)
header = pn.Row( icon_numbers, pn.Spacer(width=30), pn.pane.HTML('<h1>Panel VSC </h1>', margin=(14,0,0,0)),  pn.Spacer(width=100), text_field,
                pn.Spacer(sizing_mode='stretch_width'),
                pn.pane.SVG(svg_subject,margin=tm, css_classes=['subheader']),
            pn.pane.SVG(svg_notif,margin=tm, css_classes=['subheader']), 
            pn.layout.DragMenu(sli,icon=pn.pane.SVG(svg_tune, margin=(14,0,0,0), css_classes=['subheader']), 
                                background_color='white',color='black'),
Пример #8
0
debug_text = pn.widgets.StaticText(value="debug")

plot_names = pn.widgets.MultiSelect(
    name="Plots",
    options=get_plots_list(
        df,
        filter_select.value,
        datastyle_select.value,
        number_select.value,
        category_select.value,
        compare_toggle.value,
    ),
)

plots = pn.GridBox(["placeholder"], ncols=2)


def update_df(event):
    global df
    df = get_df(repo_input.value)
    update_categories(event)
    update_plot_names(event)
    plots.objects = []


submit_button.on_click(update_df)


def update_categories(event):
    category_select.options = allowed_categories[datastyle_select.value]
Пример #9
0
    def view(self):
        self.station_input = pn.widgets.AutocompleteInput(
            name='ASOS Station ID',
            options=self.stations,
            align='center',
            value='CMI',
            width=300)
        self.station_input.param.watch(self.update_station_input, 'value')

        self.read_data(self.station_input.value)
        self.datetime = self.df.index.max()

        self.date_input = pn.widgets.DatePicker(name='Date Selector',
                                                align='center',
                                                value=self.datetime.date(),
                                                width=300)
        self.date_input.param.watch(self.update_date_input, 'value')

        self.progress = pn.widgets.Progress(active=False,
                                            bar_color='secondary',
                                            width=300,
                                            margin=(-15, 10, 25, 10),
                                            align='center')

        title = pn.pane.Markdown(
            f'# <center>Weather<span style='
            f'"color:{RED}">Flash</span></center>',
            width=300,
            margin=(5, 10, -25, 10))

        subtitle = pn.pane.Markdown(
            f'<center>'
            f'*The selected date\'s field value is listed by the title and '
            f'highlighted in red if available. '
            f'The climatology is shown as a dashed line. '
            f'Note, the highlights below may not reflect '
            f'standard thresholds!<br><br>'
            f'The app is run on '
            f'<a href="https://www.python.org/" '
            f'target=_blank">Python</a>, '
            f'<a href="https://pandas.pydata.org/" '
            f'target=_blank">pandas</a>, '
            f'<a href="https://numpy.org/" '
            f'target=_blank">numpy</a>, '
            f'<a href="https://panel.holoviz.org/" '
            f'target=_blank">panel</a>, '
            f'<a href="http://holoviews.org/" '
            f'target=_blank">holoviews</a>, and '
            f'<a href="https://dashboard.heroku.com/" '
            f'target=_blank">Heroku</a>. '
            f'The app\'s visuals were inspired by '
            f'<a href="https://www.leagueofgraphs.com/" '
            f'target=_blank">League of Graphs</a> and '
            f'<a href="https://weatherspark.com/" '
            f'target=_blank">Weather Spark</a>.<br><br>'
            f'Comments and suggestions appreciated '
            f'<a href="https://github.com/ahuang11/weatherflash/issues" '
            f'target=_blank">here</a>!*<br>'
            f'<a href="https://github.com/ahuang11/weatherflash" '
            f'target="_blank">Source code</a> | '
            f'<a href="https://github.com/ahuang11/" '
            f'target="_blank">My GitHub</a> | '
            f'<a href="https://mesonet.agron.iastate.edu/request/daily.phtml"'
            f' target="_blank">ASOS data</a></center>',
            width=300,
            margin=(-10, 10),
            align='center')

        self.highlights = pn.GridBox(sizing_mode='stretch_width',
                                     margin=(5, 10, 0, 10),
                                     ncols=4,
                                     align='center')

        left_col = pn.Column(title,
                             self.progress,
                             self.station_input,
                             self.date_input,
                             pn.layout.Divider(),
                             subtitle,
                             pn.layout.Divider(),
                             self.highlights,
                             sizing_mode='stretch_height')

        self.tabs = pn.Tabs(sizing_mode='stretch_both',
                            margin=(10, 35),
                            tabs_location='right',
                            dynamic=True)
        self.create_content()

        layout = pn.Row(left_col, self.tabs, sizing_mode='stretch_both')
        return layout
Пример #10
0
def process_plot(cmap):
    return hv_plot.opts(cmap=cmap)


# Initialize top side widgets

horiz_spacer = pn.layout.HSpacer()

random_colors = [
    f'#{integer:06x}'
    for integer in np.random.randint(0, high=0xFFFFFF, size=9)
]
color_box = pn.GridBox(*[
    pn.pane.HTML(background=random_colors[i], width=10, height=10, margin=1)
    for i in range(9)
],
                       ncols=3,
                       margin=(15, 0))

title_markdown = pn.pane.Markdown('# <center>ColorDropper</center>\n',
                                  margin=(5, 15, 0, 15))
subtitle_markdown = pn.pane.Markdown(
    '### <center>(an online eyedropper tool)</center>', margin=(15, 0, 0, 0))
caption_markdown = pn.pane.Markdown(
    '<center>To use, paste an image url or click '
    'Choose File" to upload an image, then click on the image '
    'to get a hexcode for that clicked point!</center>\n<center>'
    '*<a href="https://github.com/ahuang11/colordropper">Source Code</a> | '
    '<a href="https://github.com/ahuang11/">Author\'s GitHub</a>*',
    sizing_mode=STR_WIDTH,
    margin=0)