本文整理汇总了Python中safe.gui.tools.minimum_needs.needs_profile.NeedsProfile.get_profiles方法的典型用法代码示例。如果您正苦于以下问题:Python NeedsProfile.get_profiles方法的具体用法?Python NeedsProfile.get_profiles怎么用?Python NeedsProfile.get_profiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe.gui.tools.minimum_needs.needs_profile.NeedsProfile
的用法示例。
在下文中一共展示了NeedsProfile.get_profiles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NeedsManagerDialog
# 需要导入模块: from safe.gui.tools.minimum_needs.needs_profile import NeedsProfile [as 别名]
# 或者: from safe.gui.tools.minimum_needs.needs_profile.NeedsProfile import get_profiles [as 别名]
#.........这里部分代码省略.........
def populate_resource_list(self):
"""Populate the list resource list.
"""
minimum_needs = self.minimum_needs.get_full_needs()
for full_resource in minimum_needs["resources"]:
self.add_resource(full_resource)
self.provenance.setText(minimum_needs["provenance"])
def clear_resource_list(self):
"""Clear the resource list.
"""
self.resources_list.clear()
def add_resource(self, resource):
"""Add a resource to the minimum needs table.
:param resource: The resource to be added
:type resource: dict
"""
updated_sentence = NeedsProfile.format_sentence(
resource['Readable sentence'], resource)
if self.edit_item:
item = self.edit_item
item.setText(updated_sentence)
self.edit_item = None
else:
item = QtGui.QListWidgetItem(updated_sentence)
item.resource_full = resource
self.resources_list.addItem(item)
def load_profiles(self):
"""Load the profiles into the dropdown list.
"""
for profile in self.minimum_needs.get_profiles():
self.profile_combo.addItem(profile)
minimum_needs = self.minimum_needs.get_full_needs()
self.profile_combo.setCurrentIndex(
self.profile_combo.findText(minimum_needs['profile']))
def select_profile(self, index):
"""Select a given profile by index.
Slot for when profile is selected.
:param index: The selected item's index
:type index: int
"""
new_profile = self.profile_combo.itemText(index)
self.resources_list.clear()
self.minimum_needs.load_profile(new_profile)
self.clear_resource_list()
self.populate_resource_list()
self.minimum_needs.save()
def select_profile_by_name(self, profile_name):
"""Select a given profile by profile name
:param profile_name: The profile name
:type profile_name: str
"""
self.select_profile(self.profile_combo.findText(profile_name))
def mark_current_profile_as_pending(self):
"""Mark the current profile as pending by colouring the text red.
"""
index = self.profile_combo.currentIndex()
示例2: NeedsManagerDialog
# 需要导入模块: from safe.gui.tools.minimum_needs.needs_profile import NeedsProfile [as 别名]
# 或者: from safe.gui.tools.minimum_needs.needs_profile.NeedsProfile import get_profiles [as 别名]
#.........这里部分代码省略.........
else:
item = QtWidgets.QListWidgetItem(updated_sentence)
item.resource_full = resource
self.resources_list.addItem(item)
def restore_defaults(self):
"""Restore defaults profiles."""
title = tr('Restore defaults')
msg = tr(
'Restoring defaults will overwrite your changes on profiles '
'provided by InaSAFE. Do you want to continue ?')
# noinspection PyCallByClass
reply = QMessageBox.question(
self,
title,
msg,
QtWidgets.QMessageBox.Yes,
QtWidgets.QMessageBox.No
)
if reply == QtWidgets.QMessageBox.Yes:
self.profile_combo.clear()
self.load_profiles(True)
# Next 2 lines fixes issues #1388 #1389 #1390 #1391
if self.profile_combo.count() > 0:
self.select_profile(0)
def load_profiles(self, overwrite=False):
"""Load the profiles into the dropdown list.
:param overwrite: If we overwrite existing profiles from the plugin.
:type overwrite: bool
"""
for profile in self.minimum_needs.get_profiles(overwrite):
self.profile_combo.addItem(profile)
minimum_needs = self.minimum_needs.get_full_needs()
self.profile_combo.setCurrentIndex(
self.profile_combo.findText(minimum_needs['profile']))
def select_profile(self, index):
"""Select a given profile by index.
Slot for when profile is selected.
:param index: The selected item's index
:type index: int
"""
new_profile = self.profile_combo.itemText(index)
self.resources_list.clear()
self.minimum_needs.load_profile(new_profile)
self.clear_resource_list()
self.populate_resource_list()
self.minimum_needs.save()
def select_profile_by_name(self, profile_name):
"""Select a given profile by profile name
:param profile_name: The profile name
:type profile_name: str
"""
self.select_profile(self.profile_combo.findText(profile_name))
def mark_current_profile_as_pending(self):
"""Mark the current profile as pending by colouring the text red.
"""
index = self.profile_combo.currentIndex()