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