本文整理汇总了Python中safe.common.version.get_version函数的典型用法代码示例。如果您正苦于以下问题:Python get_version函数的具体用法?Python get_version怎么用?Python get_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_version函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_version
def test_get_version(self):
"""Test for get_version."""
version_tuple = ('2', '2', '0', 'alpha', '0')
version = get_version(version_tuple)
if 'win32' in sys.platform or 'darwin' in sys.platform:
expected_version = '2.2.0.dev-master'
message = 'It should be %s but got %s' % (
expected_version, version)
self.assertEqual(expected_version, version, message)
else:
expected_version = '2.2.0.dev-ABCDEFG'
message = 'It should be %s but got %s' % (
expected_version[:9], version[:9])
self.assertEqual(expected_version[:9], version[:9], message)
message = 'Expected version that has length %d, got %d' % (
len(expected_version), len(version))
self.assertEqual(len(expected_version), len(version), message)
# Version tuple doesn't have length == 5
version_tuple = ('2', '2', '0', 'alpha')
self.assertRaises(RuntimeError, get_version, version_tuple)
# Version tuple item 4th is not alpha, beta, rc, final
version_tuple = ('2', '2', '0', 'avocado', '0')
self.assertRaises(RuntimeError, get_version, version_tuple)
# Final version
version_tuple = ('2', '2', '0', 'final', '0')
version = get_version(version_tuple)
self.assertEqual(version, '2.2.0', 'The version should be 2.2.0')
开发者ID:jobel-openscience,项目名称:inasafe,代码行数:30,代码来源:test_version.py
示例2: set_if_provenance
def set_if_provenance(self):
"""Set IF provenance step for the IF."""
data = {
'start_time': self._start_time ,
'finish_time': datetime.now(),
'hazard_layer': self.hazard.keywords['title'],
'exposure_layer': self.exposure.keywords['title'],
'impact_function_id': self.metadata().as_dict()['id'],
'impact_function_version': '1.0', # TODO: Add IF version.
'host_name': self.host_name,
'user': self.user,
'qgis_version': QGis.QGIS_VERSION,
'gdal_version': gdal.__version__,
'qt_version': QT_VERSION_STR,
'pyqt_version': PYQT_VERSION_STR,
'os': platform.version(),
'inasafe_version': get_version(),
# Temporary.
# TODO: Update it later.
'exposure_pixel_size': '',
'hazard_pixel_size': '',
'impact_pixel_size': '',
'analysis_extent': '',
'parameter': ''
}
self.provenance.append_if_provenance_step(
'IF Provenance',
'Impact function\'s provenance.',
timestamp=None,
data=data
)
开发者ID:felix-yew,项目名称:inasafe,代码行数:32,代码来源:base.py
示例3: download
def download(feature_type, output_base_path, extent, progress_dialog=None):
"""Download shapefiles from Kartoza server.
.. versionadded:: 3.2
:param feature_type: What kind of features should be downloaded.
Currently 'buildings', 'building-points' or 'roads' are supported.
:type feature_type: str
:param output_base_path: The base path of the shape file.
:type output_base_path: str
:param extent: A list in the form [xmin, ymin, xmax, ymax] where all
coordinates provided are in Geographic / EPSG:4326.
:type extent: list
:param progress_dialog: A progress dialog.
:type progress_dialog: QProgressDialog
:raises: ImportDialogError, CanceledImportDialogError
"""
# preparing necessary data
min_longitude = extent[0]
min_latitude = extent[1]
max_longitude = extent[2]
max_latitude = extent[3]
box = (
'{min_longitude},{min_latitude},{max_longitude},'
'{max_latitude}').format(
min_longitude=min_longitude,
min_latitude=min_latitude,
max_longitude=max_longitude,
max_latitude=max_latitude
)
url = (
'{url_osm_prefix}'
'{feature_type}'
'{url_osm_suffix}?'
'bbox={box}&'
'qgis_version={qgis}&'
'lang={lang}&'
'inasafe_version={inasafe_version}'.format(
url_osm_prefix=URL_OSM_PREFIX,
feature_type=feature_type,
url_osm_suffix=URL_OSM_SUFFIX,
box=box,
qgis=qgis_version(),
lang=locale(),
inasafe_version=get_version()))
path = tempfile.mktemp('.shp.zip')
# download and extract it
fetch_zip(url, path, feature_type, progress_dialog)
extract_zip(path, output_base_path)
if progress_dialog:
progress_dialog.done(QDialog.Accepted)
开发者ID:timlinux,项目名称:inasafe,代码行数:60,代码来源:osm_downloader.py
示例4: request
def request(self, request_url):
"""Mock handler for an http request.
:param request_url: Url being requested.
"""
url = str(request_url.url().toString())
reply = MockQNetworkReply()
if url == 'http://hot-export.geofabrik.de/newjob':
reply.content = read_all('test-importdlg-newjob.html')
elif url == 'http://hot-export.geofabrik.de/wizard_area':
reply.content = read_all('test-importdlg-wizardarea.html')
elif url == 'http://hot-export.geofabrik.de/tagupload':
reply.content = read_all('test-importdlg-job.html')
reply._url = 'http://hot-export.geofabrik.de/jobs/1990'
elif url == 'http://hot-export.geofabrik.de/jobs/1990':
reply.content = read_all('test-importdlg-job.html')
elif url == ('http://osm.inasafe.org/buildings-shp?'
'bbox=20.389938354492188,-34.10782492987083'
',20.712661743164062,'
'-34.008273470938335&qgis_version=%s'
'&inasafe_version=%s'
'&lang=en' % (qgis_version(), get_version())):
reply.content = read_all("test-importdlg-extractzip.zip")
return reply
开发者ID:inasafe,项目名称:inasafe,代码行数:25,代码来源:test_osm_downloader.py
示例5: __init__
def __init__(self, parent=None):
"""Constructor for the dialog.
:param parent: Parent widget of this dialog
:type parent: QWidget
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr('About InaSAFE %s' % get_version()))
self.parent = parent
# Set Limitations Text
limitations_text = ''
for index, limitation in enumerate(limitations()):
limitations_text += '%s. %s \n' % (index + 1, limitation)
self.limitations_text.setFontPointSize(11)
self.limitations_text.setText(limitations_text)
# Set Disclaimer Text
self.disclaimer_text.setFontPointSize(11)
self.disclaimer_text.setText(disclaimer())
# Set Attributions text
image_credits_text = ''
for index, limitation in enumerate(self.attributions()):
image_credits_text += '%s. %s \n' % (index + 1, limitation)
self.image_credits_text.setFontPointSize(11)
self.image_credits_text.setText(image_credits_text)
supporters_path = resources_path('img', 'logos', 'supporters.png')
pixmap = QtGui.QPixmap(supporters_path)
self.supporters_label.setPixmap(pixmap)
开发者ID:Mloweedgar,项目名称:inasafe,代码行数:33,代码来源:about_dialog.py
示例6: __init__
def __init__(self, parent=None):
"""Constructor for the dialog.
Show the grid converter dialog.
:param parent: parent - widget to use as parent.
:type parent: QWidget
"""
QDialog.__init__(self, parent)
self.parent = parent
self.setupUi(self)
self.setWindowTitle(
self.tr('InaSAFE %s Shakemap Converter' % get_version()))
self.warning_text = set()
self.on_input_path_textChanged()
self.on_output_path_textChanged()
self.update_warning()
# Event register
# noinspection PyUnresolvedReferences
self.use_output_default.toggled.connect(
self.get_output_from_input)
# noinspection PyUnresolvedReferences
self.input_path.textChanged.connect(self.on_input_path_textChanged)
# noinspection PyUnresolvedReferences
self.output_path.textChanged.connect(self.on_output_path_textChanged)
# Set up things for context help
self.help_button = self.button_box.button(QtGui.QDialogButtonBox.Help)
# Allow toggling the help button
self.help_button.setCheckable(True)
self.help_button.toggled.connect(self.help_toggled)
self.main_stacked_widget.setCurrentIndex(1)
开发者ID:dynaryu,项目名称:inasafe,代码行数:34,代码来源:shakemap_converter_dialog.py
示例7: load_template
def load_template(self):
"""Load the template to composition."""
# Get information for substitutions
# date, time and plugin version
date_time = self._keyword_io.read_keywords(self.layer, "time_stamp")
if date_time is None:
date = ""
time = ""
else:
tokens = date_time.split("_")
date = tokens[0]
time = tokens[1]
long_version = get_version()
tokens = long_version.split(".")
version = "%s.%s.%s" % (tokens[0], tokens[1], tokens[2])
# Get title of the layer
title = self.map_title
if not title:
title = ""
# Prepare the substitution map
substitution_map = {
"impact-title": title,
"date": date,
"time": time,
"safe-version": version,
"disclaimer": self.disclaimer,
}
# Load template
self._template_composition.substitution = substitution_map
try:
self._template_composition.load_template()
except TemplateLoadingError:
raise
开发者ID:ekaakurniawan,项目名称:jaksafe,代码行数:35,代码来源:impact_report.py
示例8: load_template
def load_template(self):
"""Load the template to composition."""
# Get information for substitutions
# date, time and plugin version
date_time = self._keyword_io.read_keywords(self.layer, 'time_stamp')
if date_time is None:
date = ''
time = ''
else:
tokens = date_time.split('_')
date = tokens[0]
time = tokens[1]
long_version = get_version()
tokens = long_version.split('.')
version = '%s.%s.%s' % (tokens[0], tokens[1], tokens[2])
# Get title of the layer
title = self.map_title
if not title:
title = ''
# Prepare the substitution map
substitution_map = {
'impact-title': title,
'date': date,
'time': time,
'safe-version': version,
'disclaimer': self.disclaimer
}
# Load template
self._template_composition.substitution = substitution_map
try:
self._template_composition.load_template()
except TemplateLoadingError:
raise
开发者ID:NyakudyaA,项目名称:inasafe,代码行数:35,代码来源:impact_report.py
示例9: __init__
def __init__(self, parent=None):
"""Constructor for the minimum needs dialog.
:param parent: Parent widget of this dialog.
:type parent: QWidget
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr(
'InaSAFE %s Minimum Needs Calculator' % get_version()))
self.polygon_layers_to_combo()
# Set up things for context help
self.help_button = self.button_box.button(QtGui.QDialogButtonBox.Help)
# Allow toggling the help button
self.help_button.setCheckable(True)
self.help_button.toggled.connect(self.help_toggled)
self.main_stacked_widget.setCurrentIndex(1)
# Fix for issue 1699 - cancel button does nothing
cancel_button = self.button_box.button(QtGui.QDialogButtonBox.Cancel)
cancel_button.clicked.connect(self.reject)
# Fix ends
ok_button = self.button_box.button(QtGui.QDialogButtonBox.Ok)
ok_button.clicked.connect(self.accept)
开发者ID:dynaryu,项目名称:inasafe,代码行数:25,代码来源:needs_calculator_dialog.py
示例10: __init__
def __init__(self, parent=None):
"""Constructor for the dialog.
Show the grid converter dialog.
:param parent: parent - widget to use as parent.
:type parent: QWidget
"""
QDialog.__init__(self, parent)
self.parent = parent
self.setupUi(self)
self.setWindowTitle(
self.tr('InaSAFE %s Shakemap Converter' % get_version()))
self.warning_text = set()
self.on_input_path_textChanged()
self.on_output_path_textChanged()
self.update_warning()
# Event register
# noinspection PyUnresolvedReferences
self.use_output_default.toggled.connect(
self.get_output_from_input)
# noinspection PyUnresolvedReferences
self.input_path.textChanged.connect(self.on_input_path_textChanged)
# noinspection PyUnresolvedReferences
self.output_path.textChanged.connect(self.on_output_path_textChanged)
# Set up things for context help
help_button = self.button_box.button(QDialogButtonBox.Help)
help_button.clicked.connect(ShakemapConverterDialog.show_help)
self.show_info()
开发者ID:tomkralidis,项目名称:inasafe,代码行数:32,代码来源:shakemap_converter_dialog.py
示例11: test_provenance_without_aggregation
def test_provenance_without_aggregation(self):
"""Test provenance of impact function without aggregation."""
hazard_layer = load_test_vector_layer(
'gisv4', 'hazard', 'classified_vector.geojson')
exposure_layer = load_test_vector_layer(
'gisv4', 'exposure', 'building-points.geojson')
hazard = definition(hazard_layer.keywords['hazard'])
exposure = definition(exposure_layer.keywords['exposure'])
hazard_category = definition(hazard_layer.keywords['hazard_category'])
expected_provenance = {
'gdal_version': gdal.__version__,
'host_name': gethostname(),
'map_title': get_map_title(hazard, exposure, hazard_category),
'map_legend_title': exposure['layer_legend_title'],
'inasafe_version': get_version(),
'pyqt_version': PYQT_VERSION_STR,
'qgis_version': QGis.QGIS_VERSION,
'qt_version': QT_VERSION_STR,
'user': getpass.getuser(),
'os': readable_os_version(),
'aggregation_layer': None,
'aggregation_layer_id': None,
'exposure_layer': exposure_layer.source(),
'exposure_layer_id': exposure_layer.id(),
'hazard_layer': hazard_layer.source(),
'hazard_layer_id': hazard_layer.id(),
'analysis_question': get_analysis_question(hazard, exposure),
'aggregation_keywords': None,
'exposure_keywords': deepcopy(exposure_layer.keywords),
'hazard_keywords': deepcopy(hazard_layer.keywords),
}
# Set up impact function
impact_function = ImpactFunction()
impact_function.exposure = exposure_layer
impact_function.hazard = hazard_layer
status, message = impact_function.prepare()
self.assertEqual(PREPARE_SUCCESS, status, message)
status, message = impact_function.run()
self.assertEqual(ANALYSIS_SUCCESS, status, message)
self.maxDiff = None
expected_provenance.update({
'action_checklist': impact_function.action_checklist(),
'analysis_extent': impact_function.analysis_extent.exportToWkt(),
'impact_function_name': impact_function.name,
'impact_function_title': impact_function.title,
'notes': impact_function.notes(),
'requested_extent': impact_function.requested_extent,
'data_store_uri': impact_function.datastore.uri_path,
'start_datetime': impact_function.start_datetime,
'end_datetime': impact_function.end_datetime,
'duration': impact_function.duration
})
self.assertDictEqual(expected_provenance, impact_function.provenance)
开发者ID:ismailsunni,项目名称:inasafe,代码行数:59,代码来源:test_impact_function.py
示例12: download
def download(feature_type, output_base_path, extent, progress_dialog=None):
"""Download shapefiles from Kartoza server.
.. versionadded:: 3.2
:param feature_type: What kind of features should be downloaded.
Currently 'buildings', 'building-points' or 'roads' are supported.
:type feature_type: str
:param output_base_path: The base path of the shape file.
:type output_base_path: str
:param extent: A list in the form [xmin, ymin, xmax, ymax] where all
coordinates provided are in Geographic / EPSG:4326.
:type extent: list
:param progress_dialog: A progress dialog.
:type progress_dialog: QProgressDialog
:raises: ImportDialogError, CanceledImportDialogError
"""
# preparing necessary data
min_longitude = extent[0]
min_latitude = extent[1]
max_longitude = extent[2]
max_latitude = extent[3]
box = (
'{min_longitude},{min_latitude},{max_longitude},'
'{max_latitude}').format(
min_longitude=min_longitude,
min_latitude=min_latitude,
max_longitude=max_longitude,
max_latitude=max_latitude
)
url = URL_OSM_PREFIX + feature_type + URL_OSM_SUFFIX
url = '{url}?bbox={box}&qgis_version={qgis}'.format(
url=url, box=box, qgis=qgis_version())
url += '&inasafe_version=%s' % get_version()
if 'LANG' in os.environ:
# Get the language only : eg 'en_US' -> 'en'
env_lang = os.environ['LANG'].split('_')[0]
url += '&lang=%s' % env_lang
path = tempfile.mktemp('.shp.zip')
# download and extract it
fetch_zip(url, path, feature_type, progress_dialog)
extract_zip(path, output_base_path)
if progress_dialog:
progress_dialog.done(QDialog.Accepted)
开发者ID:codeforresilience,项目名称:inasafe,代码行数:56,代码来源:osm_downloader.py
示例13: __init__
def __init__(self, parent=None):
"""Constructor for the minimum needs dialog.
:param parent: Parent widget of this dialog.
:type parent: QWidget
"""
QtWidgets.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr(
'InaSAFE %s Minimum Needs Calculator' % get_version()))
icon = resources_path('img', 'icons', 'show-minimum-needs.svg')
self.setWindowIcon(QtGui.QIcon(icon))
self.result_layer = None
self.button_box.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
# get qgis map layer combobox object
self.layer.setFilters(QgsMapLayerProxyModel.VectorLayer)
# get field that represent displaced count(population)
self.displaced.setFilters(QgsFieldProxyModel.Numeric)
# get field that represent aggregation name
self.aggregation_name.setFilters(QgsFieldProxyModel.String)
# set field to the current selected layer
self.displaced.setLayer(self.layer.currentLayer())
self.aggregation_name.setLayer(self.layer.currentLayer())
self.aggregation_id.setLayer(self.layer.currentLayer())
# link map layer and field combobox
self.layer.layerChanged.connect(self.displaced.setLayer)
self.layer.layerChanged.connect(self.aggregation_name.setLayer)
self.layer.layerChanged.connect(self.aggregation_id.setLayer)
# enable/disable ok button
self.update_button_status()
self.displaced.fieldChanged.connect(self.update_button_status)
# Set up things for context help
self.help_button = self.button_box.button(
QtWidgets.QDialogButtonBox.Help)
# Allow toggling the help button
self.help_button.setCheckable(True)
self.help_button.toggled.connect(self.help_toggled)
self.main_stacked_widget.setCurrentIndex(1)
# Fix for issue 1699 - cancel button does nothing
cancel_button = self.button_box.button(
QtWidgets.QDialogButtonBox.Cancel)
cancel_button.clicked.connect(self.reject)
# Fix ends
ok_button = self.button_box.button(QtWidgets.QDialogButtonBox.Ok)
ok_button.clicked.connect(self.accept)
开发者ID:inasafe,项目名称:inasafe,代码行数:54,代码来源:needs_calculator_dialog.py
示例14: heading
def heading():
"""Helper method that returns just the header.
This method was added so that the text could be reused in the
other contexts.
.. versionadded:: 4.0.0
:returns: A heading object.
:rtype: safe.messaging.heading.Heading
"""
message = m.Heading(
'{} {}'.format(tr('InaSAFE help'), get_version()), **TITLE_STYLE)
return message
开发者ID:inasafe,项目名称:inasafe,代码行数:14,代码来源:definitions_help.py
示例15: __init__
def __init__(self, iface, dock=None, parent=None):
"""Constructor for the dialog.
:param iface: A Quantum GIS QGisAppInterface instance.
:type iface: QGisAppInterface
:param parent: Parent widget of this dialog
:type parent: QWidget
:param dock: Optional dock widget instance that we can notify of
changes to the keywords.
:type dock: Dock
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr('InaSAFE %s Options' % get_version()))
# Save reference to the QGIS interface and parent
self.iface = iface
self.parent = parent
self.dock = dock
self.keyword_io = KeywordIO()
self.defaults = get_defaults()
# Set up things for context help
self.help_button = self.button_box.button(QtGui.QDialogButtonBox.Help)
# Allow toggling the help button
self.help_button.setCheckable(True)
self.help_button.toggled.connect(self.help_toggled)
self.main_stacked_widget.setCurrentIndex(1)
self.grpNotImplemented.hide()
self.adjustSize()
self.restore_state()
# hack prevent showing use thread visible and set it false see #557
self.cbxUseThread.setChecked(True)
self.cbxUseThread.setVisible(False)
# Set up listener for various UI
self.custom_org_logo_checkbox.toggled.connect(
self.set_organisation_logo)
self.custom_north_arrow_checkbox.toggled.connect(self.set_north_arrow)
self.custom_UseUserDirectory_checkbox.toggled.connect(
self.set_user_dir)
self.custom_templates_dir_checkbox.toggled.connect(
self.set_templates_dir)
self.custom_org_disclaimer_checkbox.toggled.connect(
self.set_org_disclaimer)
开发者ID:dynaryu,项目名称:inasafe,代码行数:48,代码来源:options_dialog.py
示例16: show_welcome_dialog
def show_welcome_dialog(self):
"""Setup for showing welcome message dialog.
This method will setup several things:
- Only show welcome, organisation profile, and population parameter
tab. Currently, they are the first 3 tabs.
- Set the title
- Move the check box for always showing welcome message.
"""
self.welcome_layout.addWidget(self.welcome_message_check_box)
while self.tabWidget.count() > 3:
self.tabWidget.removeTab(self.tabWidget.count() - 1)
self.setWindowTitle(self.tr('Welcome to InaSAFE %s' % get_version()))
# Hide the export import button
self.export_button.hide()
self.import_button.hide()
开发者ID:inasafe,项目名称:inasafe,代码行数:16,代码来源:options_dialog.py
示例17: __init__
def __init__(self, parent=None):
"""Constructor for the minimum needs dialog.
:param parent: Parent widget of this dialog.
:type parent: QWidget
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr(
'InaSAFE %s Minimum Needs Tool' % get_version()))
self.polygon_layers_to_combo()
self.show_info()
help_button = self.button_box.button(QtGui.QDialogButtonBox.Help)
help_button.clicked.connect(self.show_help)
# Fix for issue 1699 - cancel button does nothing
cancel_button = self.button_box.button(QtGui.QDialogButtonBox.Cancel)
cancel_button.clicked.connect(self.reject)
开发者ID:NyakudyaA,项目名称:inasafe,代码行数:19,代码来源:needs_calculator_dialog.py
示例18: __init__
def __init__(self, parent=None):
"""Constructor for the dialog.
:param parent: Parent widget of this dialog
:type parent: QWidget
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr('InaSAFE %s Help' % get_version()))
self.parent = parent
header = html_header()
footer = html_footer()
string = header
message = dock_help()
string += message.to_html()
string += footer
self.help_web_view.setHtml(string)
开发者ID:easmetz,项目名称:inasafe,代码行数:23,代码来源:help_dialog.py
示例19: __init__
def __init__(self, iface, parent=None, qsetting=''):
"""Constructor for the dialog.
:param iface: A Quantum GIS QGisAppInterface instance.
:type iface: QGisAppInterface
:param parent: Parent widget of this dialog
:type parent: QWidget
:param qsetting: String to specify the QSettings. By default,
use empty string.
:type qsetting: str
"""
QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr('InaSAFE %s Options' % get_version()))
# Save reference to the QGIS interface and parent
self.iface = iface
self.parent = parent
if qsetting:
self.settings = QSettings(qsetting)
else:
self.settings = QSettings()
# InaSAFE default values
self.default_value_parameters = []
self.default_value_parameter_containers = []
# Flag for restore default values
self.is_restore_default = False
# List of setting key and control
self.boolean_settings = {
'visibleLayersOnlyFlag': self.cbxVisibleLayersOnly,
'set_layer_from_title_flag': self.cbxSetLayerNameFromTitle,
'setZoomToImpactFlag': self.cbxZoomToImpact,
'set_show_only_impact_on_report': self.cbx_show_only_impact,
'setHideExposureFlag': self.cbxHideExposure,
'useSelectedFeaturesOnly': self.cbxUseSelectedFeaturesOnly,
'useSentry': self.cbxUseSentry,
'template_warning_verbose': self.template_warning_checkbox,
'showOrganisationLogoInDockFlag':
self.organisation_on_dock_checkbox,
'developer_mode': self.cbxDevMode,
'generate_report': self.checkbox_generate_reports,
'memory_profile': self.check_box_memory
}
self.text_settings = {
'keywordCachePath': self.leKeywordCachePath,
'ISO19115_ORGANIZATION': self.iso19115_organization_le,
'ISO19115_URL': self.iso19115_url_le,
'ISO19115_EMAIL': self.iso19115_email_le,
'ISO19115_LICENSE': self.iso19115_license_le,
}
# Set up things for context help
self.help_button = self.button_box.button(QDialogButtonBox.Help)
# Allow toggling the help button
self.help_button.setCheckable(True)
self.help_button.toggled.connect(self.help_toggled)
self.main_stacked_widget.setCurrentIndex(1)
# Always set first tab to be open, 0-th index
self.tabWidget.setCurrentIndex(0)
# Hide not implemented group
self.grpNotImplemented.hide()
self.adjustSize()
# Demographic tab
self.scroll_area = QScrollArea()
self.scroll_area.setWidgetResizable(True)
self.widget_container = QWidget()
self.scroll_area.setWidget(self.widget_container)
self.container_layout = QVBoxLayout()
self.widget_container.setLayout(self.container_layout)
self.default_values_layout.addWidget(self.scroll_area)
self.restore_state()
# Hide checkbox if not developers
if not self.cbxDevMode.isChecked():
self.checkbox_generate_reports.hide()
# Set up listener for various UI
self.custom_org_logo_checkbox.toggled.connect(
self.set_organisation_logo)
self.custom_north_arrow_checkbox.toggled.connect(self.set_north_arrow)
self.custom_UseUserDirectory_checkbox.toggled.connect(
self.set_user_dir)
self.custom_templates_dir_checkbox.toggled.connect(
self.set_templates_dir)
self.custom_org_disclaimer_checkbox.toggled.connect(
self.set_org_disclaimer)
# Set up listener for restore defaults button
self.restore_defaults = self.button_box_restore_defaults.button(
QDialogButtonBox.RestoreDefaults)
self.restore_defaults.setCheckable(True)
#.........这里部分代码省略.........
开发者ID:ismailsunni,项目名称:inasafe,代码行数:101,代码来源:options_dialog.py
示例20: __init__
def __init__(self, parent, iface, dock=None, layer=None):
"""Constructor for the dialog.
.. note:: In QtDesigner the advanced editor's predefined keywords
list should be shown in english always, so when adding entries to
cboKeyword, be sure to choose :safe_qgis:`Properties<<` and untick
the :safe_qgis:`translatable` property.
:param parent: Parent widget of this dialog.
:type parent: QWidget
:param iface: Quantum GIS QGisAppInterface instance.
:type iface: QGisAppInterface
:param dock: Dock widget instance that we can notify of changes to
the keywords. Optional.
:type dock: Dock
"""
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(self.tr(
'InaSAFE %s Keywords Editor' % get_version()))
# Save reference to the QGIS interface and parent
self.iface = iface
self.parent = parent
self.dock = dock
self.defaults = None
# string constants
self.global_default_string = metadata.global_default_attribute['name']
self.do_not_use_string = metadata.do_not_use_attribute['name']
self.global_default_data = metadata.global_default_attribute['id']
self.do_not_use_data = metadata.do_not_use_attribute['id']
if layer is None:
self.layer = self.iface.activeLayer()
else:
self.layer = layer
self.keyword_io = KeywordIO()
# note the keys should remain untranslated as we need to write
# english to the keywords file. The keys will be written as user data
# in the combo entries.
# .. seealso:: http://www.voidspace.org.uk/python/odict.html
self.standard_exposure_list = OrderedDict(
[('population', self.tr('population')),
('structure', self.tr('structure')),
('road', self.tr('road')),
('Not Set', self.tr('Not Set'))])
self.standard_hazard_list = OrderedDict(
[('earthquake [MMI]', self.tr('earthquake [MMI]')),
('tsunami [m]', self.tr('tsunami [m]')),
('tsunami [wet/dry]', self.tr('tsunami [wet/dry]')),
('tsunami [feet]', self.tr('tsunami [feet]')),
('flood [m]', self.tr('flood [m]')),
('flood [wet/dry]', self.tr('flood [wet/dry]')),
('flood [feet]', self.tr('flood [feet]')),
('tephra [kg2/m2]', self.tr('tephra [kg2/m2]')),
('volcano', self.tr('volcano')),
('generic [categorised]', self.tr('generic [categorised]')),
('Not Set', self.tr('Not Set'))])
# noinspection PyUnresolvedReferences
self.lstKeywords.itemClicked.connect(self.edit_key_value_pair)
# Set up help dialog showing logic.
help_button = self.buttonBox.button(QtGui.QDialogButtonBox.Help)
help_button.clicked.connect(self.show_help)
if self.layer is not None and is_polygon_layer(self.layer):
# set some initial ui state:
self.defaults = get_defaults()
self.radPredefined.setChecked(True)
self.dsbFemaleRatioDefault.blockSignals(True)
self.dsbFemaleRatioDefault.setValue(self.defaults['FEMALE_RATIO'])
self.dsbFemaleRatioDefault.blockSignals(False)
self.dsbYouthRatioDefault.blockSignals(True)
self.dsbYouthRatioDefault.setValue(self.defaults['YOUTH_RATIO'])
self.dsbYouthRatioDefault.blockSignals(False)
self.dsbAdultRatioDefault.blockSignals(True)
self.dsbAdultRatioDefault.setValue(self.defaults['ADULT_RATIO'])
self.dsbAdultRatioDefault.blockSignals(False)
self.dsbElderlyRatioDefault.blockSignals(True)
self.dsbElderlyRatioDefault.setValue(
self.defaults['ELDERLY_RATIO'])
self.dsbElderlyRatioDefault.blockSignals(False)
else:
self.radPostprocessing.hide()
self.tab_widget.removeTab(1)
if self.layer:
self.load_state_from_keywords()
# add a reload from keywords button
reload_button = self.buttonBox.addButton(
self.tr('Reload'), QtGui.QDialogButtonBox.ActionRole)
#.........这里部分代码省略.........
开发者ID:severinmenard,项目名称:inasafe,代码行数:101,代码来源:keywords_dialog.py
注:本文中的safe.common.version.get_version函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论