sean@16: #!/usr/bin/env python3 sean@16: sean@16: """ Simple Template to use the Web-View Module sean@16: sean@16: author: Sean Engelhardt sean@16: sean@16: (c) 2010,2015 by Intevation GmbH sean@16: sean@16: This is Free Software unter the terms of the sean@16: GNU GENERAL PUBLIC LICENSE Version 3 or later. sean@16: See http://www.gnu.org/licenses/gpl-3.0.txt for details sean@16: sean@16: --- sean@16: How to write a web-view module? sean@16: --- sean@16: sean@16: declare a specific tile in the dash.conf. for example: sean@16: sean@16: --- sean@16: [tile5] sean@16: type=d3js sean@16: div_name=webview_test sean@16: script=webview_template sean@16: --- sean@16: (this will work for this file, see dash.conf for details) sean@16: sean@16: bottledash will look for a "get_chart(target_div_name)"-methode wich shall sean@16: return valid HTML-code (as string!). sean@16: sean@16: the "target_div_name" is the "div_name" you delared in the dash.conf-file. sean@16: In our case, "tile5" would be in the css-class "webview_test". You can use sean@16: the "target_div_name" for dynamic DOM-Manipulations (like with d3js and jQuery) sean@16: sean@16: If you want to use a python import, please use "importlib" inside the sean@16: get_chart-function. sean@16: sean@16: see for details sean@16: sean@16: To not try to import your own modules using the regular sean@16: python import-keyword! You can however import every regular sean@16: python-standard-library using the "import" keyword sean@16: sean@16: """ sean@16: sean@16: import importlib sean@16: sean@16: def get_chart(target_div_name): sean@16: html_string = """ sean@16: sean@16: sean@16:
sean@16: Hello World! sean@16:
sean@16: """ % target_div_name sean@16: sean@16: return html_string