本文整理汇总了Python中qgis.PyQt.QtWidgets.QProgressBar类的典型用法代码示例。如果您正苦于以下问题:Python QProgressBar类的具体用法?Python QProgressBar怎么用?Python QProgressBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QProgressBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MessageBarProgress
class MessageBarProgress(QgsProcessingFeedback):
def __init__(self, algname=None):
QgsProcessingFeedback.__init__(self)
self.msg = []
self.progressMessageBar = \
iface.messageBar().createMessage(self.tr('Executing algorithm <i>{0}</i>'.format(algname if algname else '')))
self.progress = QProgressBar()
self.progressChanged.connect(self.progress.setValue)
self.progress.setMaximum(100)
self.progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
self.progressMessageBar.layout().addWidget(self.progress)
self.message_bar_item = iface.messageBar().pushWidget(self.progressMessageBar,
Qgis.Info)
def reportError(self, msg, fatalError=False):
self.msg.append(msg)
def close(self):
if self.msg:
dlg = MessageDialog()
dlg.setTitle(QCoreApplication.translate('MessageBarProgress', 'Problem executing algorithm'))
dlg.setMessage("<br>".join(self.msg))
dlg.exec_()
iface.messageBar().popWidget(self.message_bar_item)
def tr(self, string, context=''):
if context == '':
context = 'MessageBarProgress'
return QCoreApplication.translate(context, string)
示例2: ProgressBarLogger
class ProgressBarLogger(QDialog):
"""A simple dialog with a progress bar and a label"""
def __init__(self, title = None):
QDialog.__init__(self, None)
if title is not None:
self.setWindowTitle(title)
self.__label = QLabel(self)
self.__layout = QVBoxLayout()
self.__layout.addWidget(self.__label)
self.__progress = QProgressBar(self)
self.__layout.addWidget(self.__progress)
self.setLayout(self.__layout)
self.resize(600, 70)
self.setFixedSize(600, 70)
self.__progress.hide()
self.show()
def set_text(self, t):
"""Gets called when a text is to be logged"""
if isinstance(t, tuple):
lvl, msg = t
else:
msg = t
self.__label.setText(msg)
QCoreApplication.processEvents()
def set_progress(self, i, n):
"""Gets called when there is a progression"""
self.__progress.show()
self.__progress.setMinimum(0)
self.__progress.setMaximum(n)
self.__progress.setValue(i)
QCoreApplication.processEvents()
示例3: __init__
def __init__(self, algname=None):
QgsProcessingFeedback.__init__(self)
self.msg = []
self.progressMessageBar = \
iface.messageBar().createMessage(self.tr('Executing algorithm <i>{0}</i>'.format(algname if algname else '')))
self.progress = QProgressBar()
self.progressChanged.connect(self.progress.setValue)
self.progress.setMaximum(100)
self.progress.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
self.progressMessageBar.layout().addWidget(self.progress)
self.message_bar_item = iface.messageBar().pushWidget(self.progressMessageBar,
Qgis.Info)
示例4: __init__
def __init__(self, title = None):
QDialog.__init__(self, None)
if title is not None:
self.setWindowTitle(title)
self.__label = QLabel(self)
self.__layout = QVBoxLayout()
self.__layout.addWidget(self.__label)
self.__progress = QProgressBar(self)
self.__layout.addWidget(self.__progress)
self.setLayout(self.__layout)
self.resize(600, 70)
self.setFixedSize(600, 70)
self.__progress.hide()
self.show()
示例5: __init__
def __init__(self, iface):
QDialog.__init__(self, iface.mainWindow())
self.workerThread = None
self.state = False
self.outputLoc = None
self.resultStatus = None
self.reRun = False
self.savedProj = None
# Build GUI Elements
self.setWindowTitle("SEILAPLAN wird ausgeführt")
self.resize(500, 100)
self.container = QVBoxLayout()
self.progressBar = QProgressBar(self)
self.progressBar.setMinimumWidth(500)
self.statusLabel = QLabel(self)
self.hbox = QHBoxLayout()
self.cancelButton = QDialogButtonBox()
self.closeButton = QDialogButtonBox()
self.resultLabel = ClickLabel(self)
self.resultLabel.setMaximumWidth(500)
self.resultLabel.setSizePolicy(
QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding))
self.resultLabel.setWordWrap(True)
self.rerunButton = QPushButton("Berechnungen wiederholen")
self.rerunButton.setVisible(False)
spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
QSizePolicy.Minimum)
self.cancelButton.setStandardButtons(QDialogButtonBox.Cancel)
self.cancelButton.clicked.connect(self.onAbort)
self.closeButton.setStandardButtons(QDialogButtonBox.Close)
self.closeButton.clicked.connect(self.onClose)
self.hbox.addWidget(self.rerunButton)
self.hbox.addItem(spacer)
self.hbox.addWidget(self.cancelButton)
self.hbox.setAlignment(self.cancelButton, Qt.AlignHCenter)
self.hbox.addWidget(self.closeButton)
self.hbox.setAlignment(self.closeButton, Qt.AlignHCenter)
self.closeButton.hide()
self.container.addWidget(self.progressBar)
self.container.addWidget(self.statusLabel)
self.container.addWidget(self.resultLabel)
self.container.addLayout(self.hbox)
self.container.setSizeConstraint(QLayout.SetFixedSize)
self.setLayout(self.container)
示例6: on_button_box_accepted
def on_button_box_accepted(self):
if self.filenameEdit.text() == '':
QMessageBox.warning(self, self.tr("Warning!"), self.tr("Please, select a location to save the file."))
return
# Initiating processing
osmRequest = OSMRequest(self.filenameEdit.text())
osmRequest.setParameters(self.wEdit.text(), self.sEdit.text(), self.eEdit.text(), self.nEdit.text())
# Connecting end signal
osmRequest.signals.processFinished.connect(self.processFinished)
osmRequest.signals.sizeReported.connect(self.reportSize)
osmRequest.signals.proxyOpened.connect(self.proxy)
osmRequest.signals.errorOccurred.connect(self.errorOccurred)
osmRequest.signals.userCanceled.connect(self.userCanceled)
# Setting the progress bar
self.progressMessageBar = self.iface.messageBar().createMessage('Downloading data...')
self.progressBar = QProgressBar()
self.progressBar.setAlignment(Qt.AlignLeft|Qt.AlignVCenter)
self.progressMessageBar.layout().addWidget(self.progressBar)
self.iface.messageBar().pushWidget(self.progressMessageBar, Qgis.Info)
self.progressBar.setRange(0, 0)
self.progressMessageBar.destroyed.connect(osmRequest.signals.cancel)
# Starting process
self.threadpool.start(osmRequest)
示例7: NNJoinDialog
#.........这里部分代码省略.........
layerId = self.inputVectorLayer.itemData(layerindex)
inputlayer = QgsProject.instance().mapLayer(layerId)
if inputlayer is None:
self.showError(self.tr('No input layer defined'))
return
joinindex = self.joinVectorLayer.currentIndex()
joinlayerId = self.joinVectorLayer.itemData(joinindex)
joinlayer = QgsProject.instance().mapLayer(joinlayerId)
if joinlayer is None:
self.showError(self.tr('No join layer defined'))
return
if joinlayer is not None and joinlayer.crs().isGeographic():
self.showWarning('Geographic CRS used for the join layer -'
' distances will be in decimal degrees!')
outputlayername = self.outputDataset.text()
approximateinputgeom = self.approximate_input_geom_cb.isChecked()
joinprefix = self.joinPrefix.text()
# useindex = True
useindex = self.use_index_nonpoint_cb.isChecked()
useindexapproximation = self.use_indexapprox_cb.isChecked()
distancefieldname = self.distancefieldname.text()
selectedinputonly = self.inputSelected.isChecked()
selectedjoinonly = self.joinSelected.isChecked()
excludecontaining = self.exclude_containing_poly_cb.isChecked()
# create a new worker instance
self.worker = Worker(inputlayer, joinlayer, outputlayername,
joinprefix, distancefieldname,
approximateinputgeom, useindexapproximation,
useindex, selectedinputonly, selectedjoinonly,
excludecontaining)
# configure the QgsMessageBar
msgBar = self.iface.messageBar().createMessage(
self.tr('Joining'), '')
self.aprogressBar = QProgressBar()
self.aprogressBar.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
acancelButton = QPushButton()
acancelButton.setText(self.CANCEL)
# acancelButton.clicked.connect(self.killWorker)
msgBar.layout().addWidget(self.aprogressBar)
msgBar.layout().addWidget(acancelButton)
# Has to be popped after the thread has finished (in
# workerFinished).
self.iface.messageBar().pushWidget(msgBar,
Qgis.Info)
# self.iface.messageBar().INFO)
self.messageBar = msgBar
# start the worker in a new thread
self.mythread = QThread(self) # QT requires the "self"
self.worker.status.connect(self.workerInfo)
self.worker.progress.connect(self.progressBar.setValue)
self.worker.progress.connect(self.aprogressBar.setValue)
self.worker.finished.connect(self.workerFinished)
self.worker.error.connect(self.workerError)
# Must come before movetothread:
self.cancelButton.clicked.connect(self.worker.kill)
acancelButton.clicked.connect(self.worker.kill)
self.worker.finished.connect(self.worker.deleteLater)
self.worker.finished.connect(self.mythread.quit)
# self.worker.error.connect(self.worker.deleteLater)
# self.worker.error.connect(self.mythread.quit)
# Must come before thread.started.connect!:
self.worker.moveToThread(self.mythread)
self.mythread.started.connect(self.worker.run)
self.mythread.finished.connect(self.mythread.deleteLater)
self.mythread.start()
# self.thread = thread
示例8: OSMDownloaderDialog
class OSMDownloaderDialog(QDialog, FORM_CLASS):
def __init__(self, iface, startX, startY, endX, endY, parent=None):
"""Constructor."""
super(OSMDownloaderDialog, self).__init__(parent)
# Set up the user interface from Designer.
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
self.iface = iface
self.setCoordinates(startX, startY, endX, endY)
self.threadpool = QThreadPool()
self.size = 0
def setCoordinates(self, startX, startY, endX, endY):
if startX < endX:
minLong = startX
maxLong = endX
else:
minLong = endX
maxLong = startX
if startY < endY:
minLat = startY
maxLat = endY
else:
minLat = endY
maxLat = startY
self.wEdit.setText(str(minLong))
self.sEdit.setText(str(minLat))
self.eEdit.setText(str(maxLong))
self.nEdit.setText(str(maxLat))
@pyqtSlot()
def on_saveButton_clicked(self):
ret = QFileDialog.getSaveFileName(parent=None, caption='Define file name and location', filter='OSM Files(*.osm)')
fileName = ret[0]
split = fileName.split('.')
if len(split)>0 and split[-1] == 'osm':
pass
else:
fileName += '.osm'
self.filenameEdit.setText(fileName)
@pyqtSlot()
def on_button_box_accepted(self):
if self.filenameEdit.text() == '':
QMessageBox.warning(self, self.tr("Warning!"), self.tr("Please, select a location to save the file."))
return
# Initiating processing
osmRequest = OSMRequest(self.filenameEdit.text())
osmRequest.setParameters(self.wEdit.text(), self.sEdit.text(), self.eEdit.text(), self.nEdit.text())
# Connecting end signal
osmRequest.signals.processFinished.connect(self.processFinished)
osmRequest.signals.sizeReported.connect(self.reportSize)
osmRequest.signals.proxyOpened.connect(self.proxy)
osmRequest.signals.errorOccurred.connect(self.errorOccurred)
osmRequest.signals.userCanceled.connect(self.userCanceled)
# Setting the progress bar
self.progressMessageBar = self.iface.messageBar().createMessage('Downloading data...')
self.progressBar = QProgressBar()
self.progressBar.setAlignment(Qt.AlignLeft|Qt.AlignVCenter)
self.progressMessageBar.layout().addWidget(self.progressBar)
self.iface.messageBar().pushWidget(self.progressMessageBar, Qgis.Info)
self.progressBar.setRange(0, 0)
self.progressMessageBar.destroyed.connect(osmRequest.signals.cancel)
# Starting process
self.threadpool.start(osmRequest)
@pyqtSlot(str)
def proxy(self, proxy):
self.progressMessageBar.setText('Proxy set to: '+proxy)
@pyqtSlot(str)
def errorOccurred(self, message):
QMessageBox.warning(self, 'Fatal!', message)
self.close()
@pyqtSlot()
def userCanceled(self):
QMessageBox.warning(self, 'Info!', 'Process canceled by user!')
self.close()
@pyqtSlot(float)
def reportSize(self, size):
self.size = size
self.progressMessageBar.setText('Downloading: '+"{0:.2f}".format(size)+' megabytes from OSM servers...')
@pyqtSlot(str)
def processFinished(self, message):
self.progressBar.setRange(0, 100)
#.........这里部分代码省略.........
示例9: ThinGreyscaleDialog
#.........这里部分代码省略.........
def startWorker(self):
"""Initialises and starts the worker thread."""
try:
layerindex = self.inputRaster.currentIndex()
layerId = self.inputRaster.itemData(layerindex)
inputlayer = QgsProject.instance().mapLayer(layerId)
#inputlayer = QgsMapLayerRegistry.instance().mapLayer(layerId)
if inputlayer is None:
self.showError(self.tr('No input layer defined'))
return
# create a reference to the layer that is being processed
# (for use when creating the resulting raster layer)
self.thinninglayer = inputlayer
self.levels = []
#self.levelsListView.selectAll()
#selected = self.levelsListView.selectedIndexes()
if self.levelsListView.model().rowCount() == 0:
self.showInfo("Levels must be specified!")
return
for i in range(self.levelsListView.model().rowCount()):
levelstring = self.levelsListView.model().item(i).text()
#for i in selected:
# levelstring = self.levelsListView.model().itemData(i)[0]
if self.intband:
self.levels.append(int(levelstring))
else:
self.levels.append(float(levelstring))
#self.levelsListView.clearSelection()
# create a new worker instance
worker = Worker(inputlayer, self.levels, self.intband)
# configure the QgsMessageBar
msgBar = self.iface.messageBar().createMessage(
self.tr('Skeletonising'), '')
self.aprogressBar = QProgressBar()
self.aprogressBar.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
acancelButton = QPushButton()
acancelButton.setText(self.CANCEL)
acancelButton.clicked.connect(self.killWorker)
msgBar.layout().addWidget(self.aprogressBar)
msgBar.layout().addWidget(acancelButton)
# Has to be popped after the thread has finished (in
# workerFinished).
self.iface.messageBar().pushWidget(msgBar,
Qgis.Info)
self.messageBar = msgBar
# start the worker in a new thread
thread = QThread(self)
worker.moveToThread(thread)
worker.finished.connect(self.workerFinished)
worker.error.connect(self.workerError)
worker.status.connect(self.workerInfo)
worker.progress.connect(self.progressBar.setValue)
worker.progress.connect(self.aprogressBar.setValue)
worker.iterprogress.connect(self.iterProgressBar.setValue)
thread.started.connect(worker.run)
thread.start()
self.thread = thread
self.worker = worker
self.button_box.button(QDialogButtonBox.Ok).setEnabled(False)
self.button_box.button(QDialogButtonBox.Close).setEnabled(False)
self.button_box.button(QDialogButtonBox.Cancel).setEnabled(True)
except:
import traceback
self.showError(traceback.format_exc())
else:
pass
示例10: startWorker
def startWorker(self):
"""Initialises and starts the worker thread."""
try:
layerindex = self.inputRaster.currentIndex()
layerId = self.inputRaster.itemData(layerindex)
inputlayer = QgsProject.instance().mapLayer(layerId)
#inputlayer = QgsMapLayerRegistry.instance().mapLayer(layerId)
if inputlayer is None:
self.showError(self.tr('No input layer defined'))
return
# create a reference to the layer that is being processed
# (for use when creating the resulting raster layer)
self.thinninglayer = inputlayer
self.levels = []
#self.levelsListView.selectAll()
#selected = self.levelsListView.selectedIndexes()
if self.levelsListView.model().rowCount() == 0:
self.showInfo("Levels must be specified!")
return
for i in range(self.levelsListView.model().rowCount()):
levelstring = self.levelsListView.model().item(i).text()
#for i in selected:
# levelstring = self.levelsListView.model().itemData(i)[0]
if self.intband:
self.levels.append(int(levelstring))
else:
self.levels.append(float(levelstring))
#self.levelsListView.clearSelection()
# create a new worker instance
worker = Worker(inputlayer, self.levels, self.intband)
# configure the QgsMessageBar
msgBar = self.iface.messageBar().createMessage(
self.tr('Skeletonising'), '')
self.aprogressBar = QProgressBar()
self.aprogressBar.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
acancelButton = QPushButton()
acancelButton.setText(self.CANCEL)
acancelButton.clicked.connect(self.killWorker)
msgBar.layout().addWidget(self.aprogressBar)
msgBar.layout().addWidget(acancelButton)
# Has to be popped after the thread has finished (in
# workerFinished).
self.iface.messageBar().pushWidget(msgBar,
Qgis.Info)
self.messageBar = msgBar
# start the worker in a new thread
thread = QThread(self)
worker.moveToThread(thread)
worker.finished.connect(self.workerFinished)
worker.error.connect(self.workerError)
worker.status.connect(self.workerInfo)
worker.progress.connect(self.progressBar.setValue)
worker.progress.connect(self.aprogressBar.setValue)
worker.iterprogress.connect(self.iterProgressBar.setValue)
thread.started.connect(worker.run)
thread.start()
self.thread = thread
self.worker = worker
self.button_box.button(QDialogButtonBox.Ok).setEnabled(False)
self.button_box.button(QDialogButtonBox.Close).setEnabled(False)
self.button_box.button(QDialogButtonBox.Cancel).setEnabled(True)
except:
import traceback
self.showError(traceback.format_exc())
else:
pass
示例11: ProgressDialog
class ProgressDialog(QDialog):
""" Progress dialog shows progress bar for algorithm.
"""
def __init__(self, iface):
QDialog.__init__(self, iface.mainWindow())
self.workerThread = None
self.state = False
self.outputLoc = None
self.resultStatus = None
self.reRun = False
self.savedProj = None
# Build GUI Elements
self.setWindowTitle("SEILAPLAN wird ausgeführt")
self.resize(500, 100)
self.container = QVBoxLayout()
self.progressBar = QProgressBar(self)
self.progressBar.setMinimumWidth(500)
self.statusLabel = QLabel(self)
self.hbox = QHBoxLayout()
self.cancelButton = QDialogButtonBox()
self.closeButton = QDialogButtonBox()
self.resultLabel = ClickLabel(self)
self.resultLabel.setMaximumWidth(500)
self.resultLabel.setSizePolicy(
QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding))
self.resultLabel.setWordWrap(True)
self.rerunButton = QPushButton("Berechnungen wiederholen")
self.rerunButton.setVisible(False)
spacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
QSizePolicy.Minimum)
self.cancelButton.setStandardButtons(QDialogButtonBox.Cancel)
self.cancelButton.clicked.connect(self.onAbort)
self.closeButton.setStandardButtons(QDialogButtonBox.Close)
self.closeButton.clicked.connect(self.onClose)
self.hbox.addWidget(self.rerunButton)
self.hbox.addItem(spacer)
self.hbox.addWidget(self.cancelButton)
self.hbox.setAlignment(self.cancelButton, Qt.AlignHCenter)
self.hbox.addWidget(self.closeButton)
self.hbox.setAlignment(self.closeButton, Qt.AlignHCenter)
self.closeButton.hide()
self.container.addWidget(self.progressBar)
self.container.addWidget(self.statusLabel)
self.container.addWidget(self.resultLabel)
self.container.addLayout(self.hbox)
self.container.setSizeConstraint(QLayout.SetFixedSize)
self.setLayout(self.container)
def setThread(self, workerThread):
self.workerThread = workerThread
self.connectProgressSignals()
def connectProgressSignals(self):
# Connet signals of thread
self.workerThread.sig_jobEnded.connect(self.jobEnded)
self.workerThread.sig_jobError.connect(self.onError)
self.workerThread.sig_value.connect(self.valueFromThread)
self.workerThread.sig_range.connect(self.rangeFromThread)
self.workerThread.sig_text.connect(self.textFromThread)
self.workerThread.sig_result.connect(self.resultFromThread)
self.rerunButton.clicked.connect(self.onRerun)
def run(self):
# Show modal dialog window (QGIS is still responsive)
self.show()
# start event loop
self.exec_()
def jobEnded(self, success):
self.setWindowTitle("SEILAPLAN")
if success:
self.statusLabel.setText("Berechnungen abgeschlossen.")
self.progressBar.setValue(self.progressBar.maximum())
self.setFinalMessage()
else: # If there was an abort by the user
self.statusLabel.setText("Berechnungen abgebrochen.")
self.progressBar.setValue(self.progressBar.minimum())
self.finallyDo()
self.rerunButton.setVisible(True)
def valueFromThread(self, value):
self.progressBar.setValue(value)
def rangeFromThread(self, range_vals):
self.progressBar.setRange(range_vals[0], range_vals[1])
def maxFromThread(self, max):
self.progressBar.setValue(self.progressBar.maximum())
def textFromThread(self, value):
self.statusLabel.setText(value)
def resultFromThread(self, result):
[self.outputLoc, self.resultStatus] = result
#.........这里部分代码省略.........
示例12: startWorker
def startWorker(self):
"""Initialises and starts the worker thread."""
try:
layerindex = self.inputVectorLayer.currentIndex()
layerId = self.inputVectorLayer.itemData(layerindex)
inputlayer = QgsProject.instance().mapLayer(layerId)
if inputlayer is None:
self.showError(self.tr('No input layer defined'))
return
joinindex = self.joinVectorLayer.currentIndex()
joinlayerId = self.joinVectorLayer.itemData(joinindex)
joinlayer = QgsProject.instance().mapLayer(joinlayerId)
if joinlayer is None:
self.showError(self.tr('No join layer defined'))
return
if joinlayer is not None and joinlayer.crs().isGeographic():
self.showWarning('Geographic CRS used for the join layer -'
' distances will be in decimal degrees!')
outputlayername = self.outputDataset.text()
approximateinputgeom = self.approximate_input_geom_cb.isChecked()
joinprefix = self.joinPrefix.text()
# useindex = True
useindex = self.use_index_nonpoint_cb.isChecked()
useindexapproximation = self.use_indexapprox_cb.isChecked()
distancefieldname = self.distancefieldname.text()
selectedinputonly = self.inputSelected.isChecked()
selectedjoinonly = self.joinSelected.isChecked()
excludecontaining = self.exclude_containing_poly_cb.isChecked()
# create a new worker instance
self.worker = Worker(inputlayer, joinlayer, outputlayername,
joinprefix, distancefieldname,
approximateinputgeom, useindexapproximation,
useindex, selectedinputonly, selectedjoinonly,
excludecontaining)
# configure the QgsMessageBar
msgBar = self.iface.messageBar().createMessage(
self.tr('Joining'), '')
self.aprogressBar = QProgressBar()
self.aprogressBar.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
acancelButton = QPushButton()
acancelButton.setText(self.CANCEL)
# acancelButton.clicked.connect(self.killWorker)
msgBar.layout().addWidget(self.aprogressBar)
msgBar.layout().addWidget(acancelButton)
# Has to be popped after the thread has finished (in
# workerFinished).
self.iface.messageBar().pushWidget(msgBar,
Qgis.Info)
# self.iface.messageBar().INFO)
self.messageBar = msgBar
# start the worker in a new thread
self.mythread = QThread(self) # QT requires the "self"
self.worker.status.connect(self.workerInfo)
self.worker.progress.connect(self.progressBar.setValue)
self.worker.progress.connect(self.aprogressBar.setValue)
self.worker.finished.connect(self.workerFinished)
self.worker.error.connect(self.workerError)
# Must come before movetothread:
self.cancelButton.clicked.connect(self.worker.kill)
acancelButton.clicked.connect(self.worker.kill)
self.worker.finished.connect(self.worker.deleteLater)
self.worker.finished.connect(self.mythread.quit)
# self.worker.error.connect(self.worker.deleteLater)
# self.worker.error.connect(self.mythread.quit)
# Must come before thread.started.connect!:
self.worker.moveToThread(self.mythread)
self.mythread.started.connect(self.worker.run)
self.mythread.finished.connect(self.mythread.deleteLater)
self.mythread.start()
# self.thread = thread
# self.worker = worker
self.button_box.button(QDialogButtonBox.Ok).setEnabled(False)
self.button_box.button(QDialogButtonBox.Close).setEnabled(False)
self.button_box.button(QDialogButtonBox.Cancel).setEnabled(True)
if layerId == joinlayerId:
self.showInfo("The join layer is the same as the"
" input layer - doing a self join!")
except:
import traceback
self.showError("Error starting worker: " + traceback.format_exc())
else:
pass
示例13: setupUi
#.........这里部分代码省略.........
self.label_6 = QLabel(self.scrollAreaWidgetContents)
self.label_6.setObjectName("label_6")
self.verticalLayout_2.addWidget(self.label_6)
self.comboTaxonField = QComboBox(self.scrollAreaWidgetContents)
self.comboTaxonField.setObjectName("comboTaxonField")
self.verticalLayout_2.addWidget(self.comboTaxonField)
self.gridLayout_6.addLayout(self.verticalLayout_2, 2, 0, 1, 1)
self.verticalLayout_5 = QVBoxLayout()
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.label_9 = QLabel(self.scrollAreaWidgetContents)
self.label_9.setObjectName("label_9")
self.verticalLayout_5.addWidget(self.label_9)
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.leOutDir = QLineEdit(self.scrollAreaWidgetContents)
self.leOutDir.setPlaceholderText("")
self.leOutDir.setObjectName("leOutDir")
self.horizontalLayout.addWidget(self.leOutDir)
self.btnBrowse = QPushButton(self.scrollAreaWidgetContents)
self.btnBrowse.setObjectName("btnBrowse")
self.horizontalLayout.addWidget(self.btnBrowse)
self.verticalLayout_5.addLayout(self.horizontalLayout)
self.gridLayout_6.addLayout(self.verticalLayout_5, 5, 0, 1, 1)
self.verticalLayout_6 = QVBoxLayout()
self.verticalLayout_6.setObjectName("verticalLayout_6")
self.label = QLabel(self.scrollAreaWidgetContents)
self.label.setObjectName("label")
self.verticalLayout_6.addWidget(self.label)
self.gridLayout = QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.label_2 = QLabel(self.scrollAreaWidgetContents)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)
self.comboSecondary = QComboBox(self.scrollAreaWidgetContents)
self.comboSecondary.setObjectName("comboSecondary")
self.gridLayout.addWidget(self.comboSecondary, 1, 1, 1, 1)
self.comboSurface = QComboBox(self.scrollAreaWidgetContents)
self.comboSurface.setObjectName("comboSurface")
self.gridLayout.addWidget(self.comboSurface, 2, 1, 1, 1)
self.label_3 = QLabel(self.scrollAreaWidgetContents)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1)
self.label_4 = QLabel(self.scrollAreaWidgetContents)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 2, 0, 1, 1)
self.comboBase = QComboBox(self.scrollAreaWidgetContents)
self.comboBase.setObjectName("comboBase")
self.gridLayout.addWidget(self.comboBase, 0, 1, 1, 1)
self.gridLayout.setColumnStretch(0, 1)
self.gridLayout.setColumnStretch(1, 3)
self.verticalLayout_6.addLayout(self.gridLayout)
self.gridLayout_6.addLayout(self.verticalLayout_6, 0, 0, 1, 1)
self.verticalLayout_3 = QVBoxLayout()
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.label_7 = QLabel(self.scrollAreaWidgetContents)
self.label_7.setObjectName("label_7")
self.verticalLayout_3.addWidget(self.label_7)
self.comboGrid = QComboBox(self.scrollAreaWidgetContents)
self.comboGrid.setObjectName("comboGrid")
self.verticalLayout_3.addWidget(self.comboGrid)
self.verticalLayout_4 = QVBoxLayout()
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.label_8 = QLabel(self.scrollAreaWidgetContents)
self.label_8.setObjectName("label_8")
self.verticalLayout_4.addWidget(self.label_8)
self.gridLayout_2 = QGridLayout()
self.gridLayout_2.setObjectName("gridLayout_2")
self.leMaxY = QLineEdit(self.scrollAreaWidgetContents)
self.leMaxY.setObjectName("leMaxY")
self.gridLayout_2.addWidget(self.leMaxY, 0, 1, 1, 1)
self.leMinX = QLineEdit(self.scrollAreaWidgetContents)
self.leMinX.setObjectName("leMinX")
self.gridLayout_2.addWidget(self.leMinX, 1, 0, 1, 1)
self.leMaxX = QLineEdit(self.scrollAreaWidgetContents)
self.leMaxX.setObjectName("leMaxX")
self.gridLayout_2.addWidget(self.leMaxX, 1, 2, 1, 1)
self.leMinY = QLineEdit(self.scrollAreaWidgetContents)
self.leMinY.setObjectName("leMinY")
self.gridLayout_2.addWidget(self.leMinY, 2, 1, 1, 1)
self.btnExtent = QPushButton(self.scrollAreaWidgetContents)
self.btnExtent.setObjectName("btnExtent")
self.gridLayout_2.addWidget(self.btnExtent, 1, 1, 1, 1)
self.verticalLayout_4.addLayout(self.gridLayout_2)
self.verticalLayout_3.addLayout(self.verticalLayout_4)
self.gridLayout_6.addLayout(self.verticalLayout_3, 3, 0, 1, 1)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout_3.addWidget(self.scrollArea, 0, 0, 1, 1)
self.buttonBox = QDialogButtonBox(DistroMap)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout_3.addWidget(self.buttonBox, 2, 0, 1, 1)
self.progressBar = QProgressBar(DistroMap)
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.gridLayout_3.addWidget(self.progressBar, 1, 0, 1, 1)
self.retranslateUi(DistroMap)
self.buttonBox.rejected.connect(DistroMap.reject)
QMetaObject.connectSlotsByName(DistroMap)
示例14: setupUi
def setupUi(self, form1):
form1.setObjectName(_fromUtf8("form1"))
form1.resize(400, 253)
form1.setFocusPolicy(QtCore.Qt.TabFocus)
form1.setWindowTitle(_fromUtf8("Kuwahara filter"))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/qgis.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
form1.setWindowIcon(icon)
self.label = QLabel(form1)
self.label.setGeometry(QtCore.QRect(21, 10, 111, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setToolTip(_fromUtf8(""))
self.label.setObjectName(_fromUtf8("label"))
self.outputb = QPushButton(form1)
self.outputb.setGeometry(QtCore.QRect(320, 47, 31, 23))
self.outputb.setObjectName(_fromUtf8("outputb"))
self.label_2 = QLabel(form1)
self.label_2.setGeometry(QtCore.QRect(22, 49, 101, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setToolTip(_fromUtf8(""))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.progressBar = QProgressBar(form1)
self.progressBar.setGeometry(QtCore.QRect(19, 220, 361, 23))
self.progressBar.setProperty(_fromUtf8("value"), 24)
self.progressBar.setObjectName(_fromUtf8("progressBar"))
self.label_3 = QLabel(form1)
self.label_3.setGeometry(QtCore.QRect(22, 88, 131, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_3.setFont(font)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QLabel(form1)
self.label_4.setGeometry(QtCore.QRect(21, 125, 181, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_4.setFont(font)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.run = QPushButton(form1)
self.run.setGeometry(QtCore.QRect(139, 185, 101, 23))
self.run.setObjectName(_fromUtf8("run"))
self.inputbox = QgsMapLayerComboBox(form1)
self.inputbox.setGeometry(QtCore.QRect(141, 10, 170, 22))
self.inputbox.setObjectName(_fromUtf8("input"))
self.output = QLineEdit(form1)
self.output.setGeometry(QtCore.QRect(149, 45, 160, 28))
self.output.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.output.setObjectName(_fromUtf8("output"))
self.refb = QLineEdit(form1)
self.refb.setGeometry(QtCore.QRect(149, 82, 160, 28))
self.refb.setObjectName(_fromUtf8("refb"))
self.mem = QLineEdit(form1)
self.mem.setGeometry(QtCore.QRect(208, 120, 101, 28))
self.mem.setObjectName(_fromUtf8("mem"))
self.addout = QCheckBox(form1)
self.addout.setGeometry(QtCore.QRect(100, 158, 171, 17))
self.addout.setChecked(True)
self.addout.setObjectName(_fromUtf8("checkBox"))
self.inputb = QPushButton(form1)
self.inputb.setGeometry(QtCore.QRect(320, 10, 31, 23))
self.inputb.setObjectName(_fromUtf8("inputb"))
self.retranslateUi(form1)
self.setWindowFlags(QtCore.Qt.WindowFlags(QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint))
QtCore.QMetaObject.connectSlotsByName(form1)
示例15: Ui_form1
class Ui_form1(object):
def setupUi(self, form1):
form1.setObjectName(_fromUtf8("form1"))
form1.resize(400, 253)
form1.setFocusPolicy(QtCore.Qt.TabFocus)
form1.setWindowTitle(_fromUtf8("Kuwahara filter"))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/qgis.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
form1.setWindowIcon(icon)
self.label = QLabel(form1)
self.label.setGeometry(QtCore.QRect(21, 10, 111, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setToolTip(_fromUtf8(""))
self.label.setObjectName(_fromUtf8("label"))
self.outputb = QPushButton(form1)
self.outputb.setGeometry(QtCore.QRect(320, 47, 31, 23))
self.outputb.setObjectName(_fromUtf8("outputb"))
self.label_2 = QLabel(form1)
self.label_2.setGeometry(QtCore.QRect(22, 49, 101, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setToolTip(_fromUtf8(""))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.progressBar = QProgressBar(form1)
self.progressBar.setGeometry(QtCore.QRect(19, 220, 361, 23))
self.progressBar.setProperty(_fromUtf8("value"), 24)
self.progressBar.setObjectName(_fromUtf8("progressBar"))
self.label_3 = QLabel(form1)
self.label_3.setGeometry(QtCore.QRect(22, 88, 131, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_3.setFont(font)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QLabel(form1)
self.label_4.setGeometry(QtCore.QRect(21, 125, 181, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_4.setFont(font)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.run = QPushButton(form1)
self.run.setGeometry(QtCore.QRect(139, 185, 101, 23))
self.run.setObjectName(_fromUtf8("run"))
self.inputbox = QgsMapLayerComboBox(form1)
self.inputbox.setGeometry(QtCore.QRect(141, 10, 170, 22))
self.inputbox.setObjectName(_fromUtf8("input"))
self.output = QLineEdit(form1)
self.output.setGeometry(QtCore.QRect(149, 45, 160, 28))
self.output.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
self.output.setObjectName(_fromUtf8("output"))
self.refb = QLineEdit(form1)
self.refb.setGeometry(QtCore.QRect(149, 82, 160, 28))
self.refb.setObjectName(_fromUtf8("refb"))
self.mem = QLineEdit(form1)
self.mem.setGeometry(QtCore.QRect(208, 120, 101, 28))
self.mem.setObjectName(_fromUtf8("mem"))
self.addout = QCheckBox(form1)
self.addout.setGeometry(QtCore.QRect(100, 158, 171, 17))
self.addout.setChecked(True)
self.addout.setObjectName(_fromUtf8("checkBox"))
self.inputb = QPushButton(form1)
self.inputb.setGeometry(QtCore.QRect(320, 10, 31, 23))
self.inputb.setObjectName(_fromUtf8("inputb"))
self.retranslateUi(form1)
self.setWindowFlags(QtCore.Qt.WindowFlags(QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowCloseButtonHint))
QtCore.QMetaObject.connectSlotsByName(form1)
def retranslateUi(self, form1):
self.label.setText(QtCore.QCoreApplication.translate("form1", "Input raster"))
self.outputb.setText("...")
self.label_2.setText(QApplication.translate("form1", "Output raster"))
self.label_3.setToolTip(QApplication.translate("form1", "Reference band from which variances will be calculated to choose subwindow mean."))
self.label_3.setText(QApplication.translate("form1", "Reference band"))
self.label_4.setToolTip(QApplication.translate("form1", "Maximum memory usage in megabytes (it is an approximated value, since algorithm will only choose how many lines will be read at once)."))
self.label_4.setText(QApplication.translate("form1", "Max memory usage (MB)"))
self.run.setText(QApplication.translate("form1", "Run"))
self.output.setPlaceholderText(QApplication.translate("form1", "<temporary file>"))
self.refb.setToolTip(QApplication.translate("form1", "Reference band from which variances will be calculated to choose subwindow mean."))
self.refb.setText("1")
self.mem.setToolTip(QApplication.translate("form1", "Maximum memory usage in MeB (it is an approximated value, since algorithm will only choose how many lines will be read at once)."))
self.mem.setText("100")
self.addout.setText(QApplication.translate("form1", "Add results to project"))
self.inputb.setText("...")