本文整理汇总了Python中PyQt4.QtCore.QThreadPool.activeThreadCount方法的典型用法代码示例。如果您正苦于以下问题:Python QThreadPool.activeThreadCount方法的具体用法?Python QThreadPool.activeThreadCount怎么用?Python QThreadPool.activeThreadCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QThreadPool
的用法示例。
在下文中一共展示了QThreadPool.activeThreadCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CatalogDialogTool
# 需要导入模块: from PyQt4.QtCore import QThreadPool [as 别名]
# 或者: from PyQt4.QtCore.QThreadPool import activeThreadCount [as 别名]
class CatalogDialogTool(QObject):
"""
Tool for managing the search and export functionality
"""
def __init__(self, iface, dialog_ui, bbox_tool):
"""
Constructor for the dialog tool
:param iface: The QGIS Interface
:param dialog_ui: The dialog GUI
:param bbox_tool The bounding box tool
:return: dialog tool
"""
QObject.__init__(self, None)
self.iface = iface
self.dialog_ui = dialog_ui
self.bbox_tool = bbox_tool
self.progress_bar = None
self.progress_message_bar = None
self.progress_message_bar_widget = None
self.search_thread_pool = QThreadPool()
self.search_lock = Lock()
self.export_thread_pool = QThreadPool()
self.export_lock = Lock()
self.query = None
self.previous_credentials = None
self.export_file = None
self.footprint_layer = None
self.filters = CatalogFilters(self.dialog_ui)
self.dialog_ui.aoi_button.clicked.connect(self.aoi_button_clicked)
self.dialog_ui.reset_button.clicked.connect(self.reset_button_clicked)
self.dialog_ui.export_button.clicked.connect(self.export_button_clicked)
self.bbox_tool.released.connect(self.search)
self.model = None
def init_progress_bar(self, progress_max):
"""
Sets up the progress bar for search functionality
:return: None
"""
if not self.progress_message_bar:
self.progress_message_bar = self.iface.messageBar().createMessage("Querying for data")
self.progress_bar = QProgressBar()
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(progress_max)
self.progress_bar.setAlignment(Qt.AlignLeft | Qt.AlignCenter)
self.progress_message_bar.layout().addWidget(self.progress_bar)
self.progress_message_bar_widget = self.iface.messageBar().pushWidget(self.progress_message_bar, self.iface.messageBar().INFO)
def init_layers(self):
"""
Sets up the layers for rendering the items
:return: None
"""
if self.footprint_layer:
QgsMapLayerRegistry.instance().removeMapLayer(self.footprint_layer.id())
self.footprint_layer = QgsVectorLayer("Polygon?crs=EPSG:4326", "Catalog Footprints", "memory")
self.footprint_layer.setCrs(QgsCoordinateReferenceSystem(4326), True)
self.footprint_layer.dataProvider().addAttributes(CatalogAcquisitionFeature.get_fields())
QgsMapLayerRegistry.instance().addMapLayer(self.footprint_layer)
def clear_widgets(self):
"""
Clears the progress bar
:return: None
"""
self.progress_bar = None
self.progress_message_bar = None
if self.progress_message_bar_widget:
self.iface.messageBar().popWidget(self.progress_message_bar_widget)
self.progress_message_bar_widget = None
def is_searching(self):
"""
Check to see if the system is still searching (checks if there's work in the search thread pool)
:return: True if searching; False otherwise
"""
return self.get_search_active_thread_count() > 0
def is_exporting(self):
"""
Check to see if the system is still exporting (checks if there's work in the export thread pool)
:return: True if searching; False otherwise
"""
return self.get_export_active_thread_count() > 0
def get_search_active_thread_count(self):
"""
Gets the number of active threads in the search thread pool
:return:
"""
with self.search_lock:
return self.search_thread_pool.activeThreadCount()
def get_export_active_thread_count(self):
"""
#.........这里部分代码省略.........