gwsumm.tabs.builtin module¶
This module defines a number of Tab subclasses.
The builtin classes provide interfaces for simple operations including
ExternalTab: embedding an existing webpage
PlotTab: scaffolding a collection of existing images
StateTab: scaffolding plots split into a number of states, with a button to switch between states in the HTML
- class gwsumm.tabs.builtin.ExternalTab(*args, **kwargs)[source]¶
Bases:
Tab
A simple tab to link HTML from an external source
- Parameters:
- namestr
name of this tab (required)
- urlstr
URL of the external content to be linked into this tab.
- indexstr
HTML file in which to write. By default each tab is written to an index.html file in its own directory. Use :attr:`~Tab.index` to find out the default index, if not given.
- shortnamestr
shorter name for this tab to use in the navigation bar. By default the regular name is used
- parent:class:`~gwsumm.tabs.Tab`
parent of this tab. This is used to position this tab in the navigation bar.
- childrenlist
list of child :class:`Tabs <~gwsumm.tabs.Tab>` of this one. This is used to position this tab in the navigation bar.
- groupstr
name of containing group for this tab in the navigation bar dropdown menu. This is only relevant if this tab has a parent.
- pathstr
base output directory for this tab (should be the same directory for all tabs in this run).
- classmethod from_ini(cp, section, *args, **kwargs)[source]¶
Configure a new ExternalTab from a ConfigParser section
- Parameters:
- cp:class:`~gwsumm.config.ConfigParser`
configuration to parse.
- sectionstr
name of section to read
See also
- :obj:`Tab.from_ini`
for documentation of the standard configuration options
Notes
On top of the standard configuration options, the ExternalTab can be configured with the
url
option, specifying the URL of the external content to be included:[tab-external] name = External data type = external url = https://www.example.org/index.html
- html_content(content)[source]¶
Build the #main div for this tab.
- Parameters:
- contentstr, ~MarkupPy.markup.page
HTML content to be wrapped
- Returns:
- #main~MarkupPy.markup.page
A new page with the input content wrapped as
- type = 'external'¶
- property url¶
- write_html(**kwargs)[source]¶
Write the HTML page for this tab.
See also
- :obj:`gwsumm.tabs.Tab.write_html`
for details of all valid keyword
- :obj:`arguments`
- class gwsumm.tabs.builtin.PlotTab(*args, **kwargs)[source]¶
Bases:
Tab
A simple tab to layout some figures in the #main div.
- Parameters:
- namestr
name of this tab (required)
- plotslist, optional
list of plots to display on this tab. More plots can be added at any time via :meth:`PlotTab.add_plot`
- layoutint, list, optional
the number of plots to display in each row, or a list of numbers to define each row individually. If the number of plots defined by the layout is less than the total number of plots, the layout for the final row will be repeated as necessary.
For example
layout=[1, 2, 3]
will display a single plot on the top row, two plots on the second, and 3 plots on each row thereafter.- foreword~MarkupPy.markup.page, str, optional
content to include in the #main HTML before the plots
- afterword~MarkupPy.markup.page, str, optional
content to include in the #main HTML after the plots
- indexstr, optional
HTML file in which to write. By default each tab is written to an index.html file in its own directory. Use :attr:`~Tab.index` to find out the default index, if not given.
- shortnamestr, optional
shorter name for this tab to use in the navigation bar. By default the regular name is used
- parent:class:`~gwsumm.tabs.Tab`, optional
parent of this tab. This is used to position this tab in the navigation bar.
- childrenlist, optional
list of child :class:`Tabs <~gwsumm.tabs.Tab>` of this one. This is used to position this tab in the navigation bar.
- groupstr, optional
name of containing group for this tab in the navigation bar dropdown menu. This is only relevant if this tab has a parent.
- pathstr, optional,
base output directory for this tab (should be the same directory for all tabs in this run).
- add_plot(plot)[source]¶
Add a plot to this tab.
- Parameters:
- plotstr, :class:`~gwsumm.plot.SummaryPlot`
either the URL of a plot to embed, or a formatted SummaryPlot object.
- property afterword¶
HTML content to be included after the plots
- property foreword¶
HTML content to be included before the plots
- classmethod from_ini(cp, section, *args, **kwargs)[source]¶
Define a new tab from a :class:`~gwsumm.config.GWConfigParser`
- Parameters:
- cp:class:`~ConfigParser.GWConfigParser`
customised configuration parser containing given section
- sectionstr
name of section to parse
- Returns:
- tabPlotTab
a new tab defined from the configuration
- html_content(content)[source]¶
Build the #main div for this tab.
- Parameters:
- contentstr, ~MarkupPy.markup.page
HTML content to be wrapped
- Returns:
- #main~MarkupPy.markup.page
A new page with the input content wrapped as
- property layout¶
List of how many plots to display on each row in the output.
By default this is
1
if the tab contains only 1 or 3 plots, or2
if otherwise. The final number given in the list will be repeated as necessary.- Type:
list of ints <int>
- scaffold_plots(plots=None, state=None, layout=None, aclass='fancybox', **fbkw)[source]¶
Build a grid of plots using bootstrap’s scaffolding.
- Returns:
- page:class:`~MarkupPy.markup.page`
formatted markup with grid of plots
- set_layout(layout)[source]¶
Set the plot scaffolding layout for this tab
- Parameters:
- lint, list of int
the desired scaffold layout, one of
an int, indicating the number of plots on every row, or
a list, indicating the number of plots on each row, with the final int repeated for any remaining rows; each entry should be an int or a pair of int indicating the number of plots on this row AND the desired the scaling of this row, see the examples…
Examples
To layout 2 plots on each row
>>> tab.set_layout(2)
or
>>> tab.set_layout([2])
To layout 2 plots on the first row, and 3 on all other rows
>>> tab.set_layout((2, 3))
To layout 2 plots on the first row, and 1 on the second row BUT have it the same size as plots on a 2-plot row
>>> tab.set_layout((2, (1, 2))
- type = 'plots'¶
- write_html(foreword=None, afterword=None, **kwargs)[source]¶
Write the HTML page for this tab.
- Parameters:
- forewordstr, :class:`~MarkupPy.markup.page`, optional
content to place above the plot grid, defaults to :attr:`PlotTab.foreword`
- afterwordstr, :class:`~MarkupPy.markup.page`, optional
content to place below the plot grid, defaults to :attr:`PlotTab.afterword`
- **kwargs
other keyword arguments to be passed through :meth:`~Tab.write_html`
See also
- :obj:`gwsumm.tabs.Tab.write_html`
for details of all valid unnamed keyword arguments
- class gwsumm.tabs.builtin.StateTab(*args, **kwargs)[source]¶
Bases:
PlotTab
Tab with multiple content pages defined via ‘states’
Each state is printed to its own HTML file which is loaded via javascript upon request into the #main div of the index for the tab.
- Parameters:
- namestr
name of this tab (required)
- stateslist
a list of states for this tab. Each state can take any form, but must be castable to a str in order to be printed.
- plotslist
list of plots to display on this tab. More plots can be added at any time via :meth:`PlotTab.add_plot`
- layoutint, list
the number of plots to display in each row, or a list of numbers to define each row individually. If the number of plots defined by the layout is less than the total number of plots, the layout for the final row will be repeated as necessary.
For example
layout=[1, 2, 3]
will display a single plot on the top row, two plots on the second, and 3 plots on each row thereafter.- indexstr
HTML file in which to write. By default each tab is written to an index.html file in its own directory. Use :attr:`~Tab.index` to find out the default index, if not given.
- shortnamestr
shorter name for this tab to use in the navigation bar. By default the regular name is used
- parent:class:`~gwsumm.tabs.Tab`
parent of this tab. This is used to position this tab in the navigation bar.
- childrenlist
list of child :class:`Tabs <~gwsumm.tabs.Tab>` of this one. This is used to position this tab in the navigation bar.
- groupstr
name of containing group for this tab in the navigation bar dropdown menu. This is only relevant if this tab has a parent.
- pathstr
base output directory for this tab (should be the same directory for all tabs in this run).
- add_state(state, default=False)[source]¶
Add a SummaryState to this tab
- Parameters:
- statestr, :class:`~gwsumm.state.SummaryState`
either the name of a state, or a SummaryState.
- registerbool, default: False
automatically register all new states
- property defaultstate¶
- property frames¶
- classmethod from_ini(cp, section, *args, **kwargs)[source]¶
Define a new tab from a :class:`~gwsumm.config.GWConfigParser`
- Parameters:
- cp:class:`~ConfigParser.GWConfigParser`
customised configuration parser containing given section
- sectionstr
name of section to parse
- Returns:
- tabPlotTab
a new tab defined from the configuration
- static html_content(frame)[source]¶
Build the #main div for this tab.
In this construction, the <div id=”id_”> is empty, with a javascript hook to load the given frame into the div when ready.
Build the navigation bar for this Tab.
The navigation bar will consist of a switch for this page linked to other interferometer servers, followed by the navbar brand, then the full dropdown-based navigation menus configured for the given
tabs
and their descendents.- Parameters:
- help_str, :class:`~MarkupPy.markup.page`
content for upper-right of navbar
- ifostr, optional
prefix for this IFO.
- ifomapdict, optional
dict of (ifo, {base url}) pairs to map to summary pages for other IFOs.
- tabslist, optional
list of parent tabs (each with a list of children) to include in the navigation bar.
- Returns:
- page~MarkupPy.markup.page
a markup page containing the navigation bar.
- property states¶
The set of :class:`states <gwsumm.state.SummaryState>` over whos times this tab’s data will be processed.
The set of states will be linked in the given order with a switch on the far-right of the HTML navigation bar.
- type = 'state'¶
- write_html(title=None, subtitle=None, tabs=[], ifo=None, ifomap={}, help_=None, css={'font-awesome': 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/fontawesome.min.css', 'font-awesome-solid': 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/solid.min.css', 'gwbootstrap': 'https://cdn.jsdelivr.net/npm/gwbootstrap@1.3.6/lib/gwbootstrap.min.css'}, js={'bootstrap': 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js', 'datepicker': 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js', 'fancybox': 'https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js', 'gwbootstrap': 'https://cdn.jsdelivr.net/npm/gwbootstrap@1.3.6/lib/gwbootstrap-extra.min.js', 'jquery': 'https://code.jquery.com/jquery-3.7.1.min.js', 'jquery-ui': 'https://code.jquery.com/ui/1.13.2/jquery-ui.min.js', 'moment': 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment.min.js'}, about=None, footer=None, **inargs)[source]¶
Write the HTML page for this state Tab.
- Parameters:
- maincontentstr, :class:`~MarkupPy.markup.page`
simple string content, or a structured page of markup to embed as the content of the #main div.
- titlestr, optional, default: {parent.name}
level 1 heading for this Tab.
- subtitlestr, optional, default: {self.name}
level 2 heading for this Tab.
- tabs: `list`, optional
list of top-level tabs (with children) to populate navbar
- ifostr, optional
prefix for this IFO.
- ifomapdict, optional
dict of (ifo, {base url}) pairs to map to summary pages for other IFOs.
- help_str, :class:`~MarkupPy.markup.page`, optional
non-menu content for navigation bar, defaults to calendar
- csslist, optional
list of resolvable URLs for CSS files. See gwsumm.html.static.CSS for the default list.
- jslist, optional
list of resolvable URLs for javascript files. See gwumm.html.JS for the default list.
- aboutstr, optional
href for the ‘About’ page
- footerstr, ~MarkupPy.markup.page
user-defined content for the footer (placed below everything else)
- **inargs
other keyword arguments to pass to the :meth:`~Tab.build_inner_html` method