本文整理匯總了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):
"""
#.........這裏部分代碼省略.........