pyiem.htmlgen module#

Utility functions that generate HTML.

pyiem.htmlgen.station_select(network, selected, name, select_all=False, only_online=False)[source]#

Select a station from a given network.

Parameters:
  • network (str) – IEM Network identifier.

  • selected (str) – The option value to flag as selected.

  • name (str) – The HTML select name attribute.

  • select_all (bool) – Add an option with key of _ALL.

  • only_online (bool) – Include stations in the network that are online only, default is False.

Return type:

html_string

pyiem.htmlgen.make_select(name, selected, data, jscallback=None, cssclass=None, multiple=False, showvalue=True)[source]#

Generate a HTML select element.

The trick here is what data looks like. The basic form is a dict. You can get optgroup by having the dictionary keys be additional lists or dicts.

Parameters:
  • name (str) – The select name attribute to assign.

  • selected (mixed) – The option value that should be set to selected.

  • data (dict) – The structure to build our select from.

  • jscallback (str) – javascript to place in the onChange attribute.

  • cssclass (str) – CSS class to assign to the select element.

  • showvalue (bool) – Should option label be prepended by key label.

Return type:

html_string