class ExampleElement(Element): loader = XMLFile(FilePath('templates/tpl_temperature.xml')) def __init__(self, temp, hum): self.temperature = temp self.hummidity = hum self.extraTemperatureContent = XMLString('<input id="temperature" type="range" min="-100" max="100" value="'+self.temperature+'" class="xwot1 sensor columns large-8" />') self.extraHumidityContent = XMLString('<input id="humidity" type="range" min="0" max="100" value="'+self.hummidity+'" class="xwot1 sensor columns large-8" />') @renderer def header(self, request, tag): return tag('Header.') @renderer def temp(self, request, tag): return self.temperature @renderer def temperatureInput(self, request, tag): return self.extraTemperatureContent.load() @renderer def humidity(self, request, tag): return self.hummidity @renderer def humidityInput(self, request, tag): return self.extraHumidityContent.load()
def render_content(self, request, tag): """ render the content for the graph container """ if self.showreel_document is not None: graph_row_xml = XMLString(self.get_content_xml()) return graph_row_xml.load() else: oops_container = self.get_bad_container() return oops_container.load()
def configuration_content(self, request, tag): """ """ set_theme = theme_helpers.get_configured_theme(self.accessor) set_style = theme_helpers.get_configured_style(self.accessor) output_string = "" output_string += "<div>" output_string += "<h3>Themes</h3>" output_string += '<div class="btn-group">' for theme in theme_helpers.get_configured_themes(): if theme == set_theme: output_string += ( "<button type=\"button\" onclick=\"setTheme" "('%s')\" class=\"%s\">%s</button>" % ( theme, "btn btn-primary", theme )) else: output_string += ( "<button type=\"button\" onclick=\"setTheme" "('%s')\" class=\"%s\">%s</button>" % ( theme, "btn btn-default", theme )) output_string += "</div>" output_string += "<h3>Colour Schemes</h3>" output_string += '<div class="btn-group">' for style in theme_helpers.get_configured_styles(): if style == set_style: output_string += ( "<button type=\"button\" onclick=\"setStyle" "('%s')\" class=\"%s\">%s</button>" % ( style, "btn btn-primary", style )) else: output_string += ( "<button type=\"button\" onclick=\"setStyle" "('%s')\" class=\"%s\">%s</button>" % ( style, "btn btn-default", style )) output_string += "</div>" output_string += "</div>" renderable_string = XMLString(output_string) return renderable_string.load()
def render_content(self, request, tag): """ render the content for the graph container """ try: graph_row_xml = XMLString(self.get_row_xml()) return graph_row_xml.load() except Exception as err: logging.error( "Exception raised when rendering graphs, exception: %r" % ( err, )) oops_container = self.get_bad_container() return oops_container.load()
def configuration_content(self, request, tag): """ get the list content """ output_string = "" output_string += '<div class="list-group">' output_string += "<div>" output_string += self.get_showreel_xml() output_string += self.get_dashboard_xml() output_string += self.get_graph_xml() output_string += self.get_data_sources_xml() output_string += "</div>" output_string += "</div>" renderable_string = XMLString(output_string) return renderable_string.load()