本文整理汇总了Python中safe_qgis.utilities.utilities.html_footer函数的典型用法代码示例。如果您正苦于以下问题:Python html_footer函数的具体用法?Python html_footer怎么用?Python html_footer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了html_footer函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_info
def show_info(self):
"""Show usage text to the user."""
header = html_header()
footer = html_footer()
string = header
heading = m.Heading(self.tr('Shakemap Grid Importer'), **INFO_STYLE)
body = self.tr(
'This tool will convert an earthquake \'shakemap\' that is in '
'grid xml format to a GeoTIFF file. The imported file can be used '
'in InaSAFE as an input for impact functions that require and '
'earthquake layer. To use this tool effectively:'
)
tips = m.BulletedList()
tips.add(self.tr(
'Select a grid.xml for the input layer.'))
tips.add(self.tr(
'Choose where to write the output layer to.'
))
tips.add(self.tr(
'Choose the interpolation algorithm that should be used when '
'converting the xml grid to a raster. If unsure keep the default.'
))
tips.add(self.tr(
'If you want to obtain shake data you can get it for free from '
'the USGS shakemap site: '
'http://earthquake.usgs.gov/earthquakes/shakemap/list.php?y=2013'))
message = m.Message()
message.add(heading)
message.add(body)
message.add(tips)
string += message.to_html()
string += footer
self.webView.setHtml(string)
示例2: loadAndWait
def loadAndWait(self, theHtmlPath=None, theHtmlSnippet=None):
"""Load some html to a web view and wait till it is done."""
if theHtmlSnippet:
myHeader = html_header()
myFooter = html_footer()
myHtml = myHeader + theHtmlSnippet + myFooter
else:
myFile = file(theHtmlPath, 'rt')
myHtml = myFile.readlines()
myFile.close()
self.webView = QtWebKit.QWebView()
myFrame = self.webView.page().mainFrame()
myFrame.setScrollBarPolicy(QtCore.Qt.Vertical,
QtCore.Qt.ScrollBarAlwaysOff)
myFrame.setScrollBarPolicy(QtCore.Qt.Horizontal,
QtCore.Qt.ScrollBarAlwaysOff)
# noinspection PyUnresolvedReferences
self.webView.loadFinished.connect(self.htmlLoadedSlot)
self.webView.setHtml(myHtml)
self.htmlLoadedFlag = False
myTimeOut = 20
myCounter = 0
mySleepPeriod = 1
while not self.htmlLoadedFlag and myCounter < myTimeOut:
# Block until the event loop is done printing the page
myCounter += 1
time.sleep(mySleepPeriod)
# noinspection PyArgumentList
QtCore.QCoreApplication.processEvents()
if not self.htmlLoadedFlag:
LOGGER.error('Failed to load html')
示例3: show_info
def show_info(self):
"""Show usage info to the user."""
# Read the header and footer html snippets
header = html_header()
footer = html_footer()
string = header
heading = m.Heading(self.tr('User Extents Tool'), **INFO_STYLE)
body = self.tr(
'This tool allows you to specify exactly which geographical '
'region should be used for your analysis. You can either '
'enter the coordinates directly into the input boxes below '
'(using the same CRS as the canvas is currently set to), or '
'you can interactively select the area by using the \'select '
'on map\' button - which will temporarily hide this window and '
'allow you to drag a rectangle on the map. After you have '
'finished dragging the rectangle, this window will reappear. '
'If you enable the \'Toggle scenario outlines\' tool on the '
'InaSAFE toolbar, your user defined extent will be shown on '
'the map as a blue rectangle. Please note that when running '
'your analysis, the effective analysis extent will be the '
'intersection of the hazard extent, exposure extent and user '
'extent - thus the entire user extent area may not be used for '
'analysis.'
)
message = m.Message()
message.add(heading)
message.add(body)
string += message.to_html()
string += footer
self.web_view.setHtml(string)
示例4: show_info
def show_info(self):
"""Show usage info to the user."""
# Read the header and footer html snippets
header = html_header()
footer = html_footer()
string = header
heading = m.Heading(self.tr('OSM Downloader'), **INFO_STYLE)
body = self.tr(
'This tool will fetch building (\'structure\') or road ('
'\'highway\') data from the OpenStreetMap project for you. '
'The downloaded data will have InaSAFE keywords defined and a '
'default QGIS style applied. To use this tool effectively:'
)
tips = m.BulletedList()
tips.add(self.tr(
'Your current extent will be used to determine the area for which '
'you want data to be retrieved. You can adjust it manually using '
'the bounding box options below.'))
tips.add(self.tr(
'Check the output directory is correct. Note that the saved '
'dataset will be called either roads.shp or buildings.shp (and '
'associated files).'
))
tips.add(self.tr(
'By default simple file names will be used (e.g. roads.shp, '
'buildings.shp). If you wish you can specify a prefix to '
'add in front of this default name. For example using a prefix '
'of \'padang-\' will cause the downloaded files to be saved as '
'\'padang-roads.shp\' and \'padang-buildings.shp\'. Note that '
'the only allowed prefix characters are A-Z, a-z, 0-9 and the '
'characters \'-\' and \'_\'. You can leave this blank if you '
'prefer.'
))
tips.add(self.tr(
'If a dataset already exists in the output directory it will be '
'overwritten.'
))
tips.add(self.tr(
'This tool requires a working internet connection and fetching '
'buildings or roads will consume your bandwidth.'))
tips.add(m.Link(
'http://www.openstreetmap.org/copyright',
text=self.tr(
'Downloaded data is copyright OpenStreetMap contributors'
' (click for more info).')
))
message = m.Message()
message.add(heading)
message.add(body)
message.add(tips)
string += message.to_html()
string += footer
self.web_view.setHtml(string)
示例5: display_html
def display_html(self, message):
"""Display rendered html output in the widget.
Given an html snippet, wrap it in a page header and footer
and display it in the wvResults widget.
:param message: An html snippet (typically a table in this context)
to display.
:type message: str or QString
"""
html = html_header() + message + html_footer()
self.webView.setHtml(html)
示例6: save_log_to_html
def save_log_to_html(self):
html = html_header()
html += ('<img src="qrc:/plugins/inasafe/inasafe-logo.svg" '
'title="InaSAFE Logo" alt="InaSAFE Logo" />')
html += ('<h5 class="info"><i class="icon-info-sign icon-white"></i> '
'%s</h5>' % self.tr('Analysis log'))
for item in self.dynamic_messages_log:
html += "%s\n" % item.to_html()
html += html_footer()
if self.log_path is not None:
html_to_file(html, self.log_path)
else:
msg = self.tr('log_path is not set')
raise InvalidParameterError(msg)
示例7: load_and_wait
def load_and_wait(self, html_path=None, html_snippet=None):
"""Load some html to a web view and wait till it is done.
:param html_path: The path to an html document (file). This option
is mutually exclusive to html_snippet.
:type html_path: str
:param html_snippet: Some html you want rendered in the form of a
string. It will be 'topped and tailed' with with standard header
and footer. This option is mutually exclusive to html_path.
:type html_snippet: str
"""
if html_snippet:
header = html_header()
footer = html_footer()
html = header + html_snippet + footer
else:
handle = file(html_path, 'rt')
html = handle.readlines()
handle.close()
self.web_view = QtWebKit.QWebView()
frame = self.web_view.page().mainFrame()
frame.setScrollBarPolicy(
QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff)
frame.setScrollBarPolicy(
QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff)
# noinspection PyUnresolvedReferences
self.html_loaded_flag = False
self.web_view.loadFinished.connect(self.html_loaded_slot)
self.web_view.setHtml(html)
my_counter = 0
my_sleep_period = 0.1 # sec
my_timeout = 20 # sec
while not self.html_loaded_flag and my_counter < my_timeout:
# Block until the event loop is done printing the page
my_counter += my_sleep_period
time.sleep(my_sleep_period)
# noinspection PyArgumentList
QtCore.QCoreApplication.processEvents()
if not self.html_loaded_flag:
LOGGER.error('Failed to load html')
# noinspection PyUnresolvedReferences
self.web_view.loadFinished.disconnect(self.html_loaded_slot)
示例8: show_info
def show_info(self):
"""Show usage info to the user."""
# Read the header and footer html snippets
header = html_header()
footer = html_footer()
string = header
heading = m.Heading(self.tr('Impact Layer Merge Tool'), **INFO_STYLE)
body = self.tr(
'This tool will merge the outputs from two impact maps for the '
'same area. The maps must be created using the same aggregation '
'areas and same hazard. To use:'
)
tips = m.BulletedList()
tips.add(self.tr(
'Run an impact assessment for an area using aggregation. e.g.'
'Flood Impact on Buildings aggregated by municipal boundaries.'))
tips.add(self.tr(
'Run a second impact assessment for the same area using the same '
'aggregation. e.g. Flood Impact on People aggregated by '
'municipal boundaries.'))
tips.add(self.tr(
'Open this tool and select each impact layer from the pick lists '
'provided below.'))
tips.add(self.tr(
'Select the aggregation layer that was used to generate the '
'first and second impact layer.'))
tips.add(self.tr(
'Select an output directory.'))
tips.add(self.tr(
'Check "Use customized report template" checkbox and select the '
'report template file if you want to use your own template. Note '
'that all the map composer components that are needed must be '
'fulfilled.'))
tips.add(self.tr(
'Click OK to generate the per aggregation area combined '
'summaries.'))
message = m.Message()
message.add(heading)
message.add(body)
message.add(tips)
string += message.to_html()
string += footer
self.web_view.setHtml(string)
示例9: show_info
def show_info(self):
"""Show usage info to the user."""
# Read the header and footer html snippets
header = html_header()
footer = html_footer()
string = header
heading = m.Heading(self.tr('OSM Downloader'), **INFO_STYLE)
body = self.tr(
'This tool will fetch building (\'structure\') or road ('
'\'highway\') data from the OpenStreetMap project for you. '
'The downloaded data will have InaSAFE keywords defined and a '
'default QGIS style applied. To use this tool effectively:'
)
tips = m.BulletedList()
tips.add(self.tr(
'Use QGIS to zoom in to the area for which you want data to be '
'retrieved.'))
tips.add(self.tr(
'Check the output directory is correct. Note that the saved '
'dataset will be called either roads.shp or buildings.shp (and '
'associated files).'
))
tips.add(self.tr(
'If a dataset already exists in the output directory it will be '
'overwritten.'
))
tips.add(self.tr(
'This tool requires a working internet connection and fetching '
'buildings or roads will consume your bandwidth.'))
tips.add(m.Link(
'http://www.openstreetmap.org/copyright',
text=self.tr(
'Downloaded data is copyright OpenStreetMap contributors'
' (click for more info).')
))
message = m.Message()
message.add(heading)
message.add(body)
message.add(tips)
string += message.to_html()
string += footer
self.web_view.setHtml(string)
示例10: show_messages
def show_messages(self):
"""Show all messages."""
string = html_header()
if self.static_message is not None:
string += self.static_message.to_html()
# Keep track of the last ID we had so we can scroll to it
self.last_id = 0
for message in self.dynamic_messages:
if message.element_id is None:
self.last_id += 1
message.element_id = str(self.last_id)
html = message.to_html(in_div_flag=True)
if html is not None:
string += html
string += html_footer()
self.setHtml(string)
示例11: update_warning
def update_warning(self):
"""Update warning message and enable/disable Ok button."""
if len(self.warning_text) == 0:
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True)
return
header = html_header()
footer = html_footer()
string = header
heading = m.Heading(self.tr('Shakemap Grid Importer'), **INFO_STYLE)
tips = m.BulletedList()
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
message = m.Message()
message.add(heading)
for warning in self.warning_text:
tips.add(warning)
message.add(tips)
string += message.to_html()
string += footer
self.webView.setHtml(string)
示例12: show_info
def show_info(self):
"""Show basic usage instructions."""
header = html_header()
footer = html_footer()
string = header
heading = m.Heading(self.tr('Minimum Needs Calculator'), **INFO_STYLE)
body = self.tr(
'This tool will calculated minimum needs for evacuated people. To '
'use this tool effectively:'
)
tips = m.BulletedList()
tips.add(self.tr(
'Load a polygon layer in QGIS. Typically the layer will '
'represent administrative districts where people have gone to an '
'evacuation center.'))
tips.add(self.tr(
'Ensure that the layer has an INTEGER attribute for the number of '
'displaced people associated with each feature.'
))
tips.add(self.tr(
'Use the pick lists below to select the layer and the population '
'field and then press \'OK\'.'
))
tips.add(self.tr(
'A new layer will be added to QGIS after the calculation is '
'complete. The layer will contain the minimum needs per district '
'/ administrative boundary.'))
message = m.Message()
message.add(heading)
message.add(body)
message.add(tips)
string += message.to_html()
string += footer
self.webView.setHtml(string)
示例13: generate_html_reports
def generate_html_reports(self, first_report_dict, second_report_dict):
"""Generate html file for each aggregation units.
It also saves the path of the each aggregation unit in
self.html_reports.
::
Ex. {"jakarta barat": "/home/jakarta barat.html",
"jakarta timur": "/home/jakarta timur.html"}
:param first_report_dict: Dictionary report from first impact.
:type first_report_dict: dict
:param second_report_dict: Dictionary report from second impact.
:type second_report_dict: dict
"""
for aggregation_area in first_report_dict:
html = html_header()
html += ('<table width="100%" style="position:absolute;left:0px;"'
'class="table table-condensed table-striped">')
html += '<caption><h4>%s</h4></caption>' % \
aggregation_area.title()
html += '<tr>'
# First impact on the left side
html += '<td width="48%">'
html += '<table width="100%">'
html += '<thead><th>%s</th></thead>' % \
self.first_impact['exposure_title'].upper()
first_exposure_report_dict = first_report_dict[aggregation_area]
for first_exposure in first_exposure_report_dict:
first_exposure_detail_dict = \
first_exposure_report_dict[first_exposure]
html += '<tr><th><i>%s</i></th><th></th></tr>' % \
first_exposure.title()
for datum in first_exposure_detail_dict:
html += ('<tr>'
'<td>%s</td>'
'<td>%s</td>'
'</tr>') % (datum,
first_exposure_detail_dict[datum])
html += '</table>'
html += '</td>'
# Second impact on the right side
if aggregation_area in second_report_dict:
# Add spaces between
html += '<td width="4%">'
html += '</td>'
# Second impact report
html += '<td width="48%">'
html += '<table width="100%">'
html += '<thead><th>%s</th></thead>' % \
self.second_impact['exposure_title'].upper()
second_exposure_report_dict = \
second_report_dict[aggregation_area]
for second_exposure in second_exposure_report_dict:
second_exposure_detail_dict = \
second_exposure_report_dict[second_exposure]
html += '<tr><th><i>%s</i></th><th></th></tr>' % \
second_exposure.title()
for datum in second_exposure_detail_dict:
html += ('<tr>'
'<td>%s</td>'
'<td>%s</td>'
'</tr>') % \
(datum,
second_exposure_detail_dict[datum])
html += '</table>'
html += '</td>'
html += '</tr>'
html += '</table>'
html += html_footer()
file_path = '%s.html' % aggregation_area
path = os.path.join(temp_dir(), file_path)
html_to_file(html, path)
self.html_reports[aggregation_area.lower()] = path