本文整理汇总了Python中qgis.PyQt.QtCore.QTimer.singleShot方法的典型用法代码示例。如果您正苦于以下问题:Python QTimer.singleShot方法的具体用法?Python QTimer.singleShot怎么用?Python QTimer.singleShot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtCore.QTimer
的用法示例。
在下文中一共展示了QTimer.singleShot方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_feature
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def test_delete_feature(self):
"""
Check if a feature can be deleted properly
"""
self.createWrapper(self.vl_a, '"name"=\'Erich Gamma\'')
self.assertEqual(self.table_view.model().rowCount(), 1)
self.assertEqual(1, len([f for f in self.vl_b.getFeatures()]))
fid = next(self.vl_b.getFeatures(QgsFeatureRequest().setFilterExpression('"name"=\'Design Patterns. Elements of Reusable Object-Oriented Software\''))).id()
self.widget.featureSelectionManager().select([fid])
btn = self.widget.findChild(QToolButton, 'mDeleteFeatureButton')
def clickOk():
# Click the "Delete features" button on the confirmation message
# box
widget = self.widget.findChild(QMessageBox)
buttonBox = widget.findChild(QDialogButtonBox)
deleteButton = next((b for b in buttonBox.buttons() if buttonBox.buttonRole(b) == QDialogButtonBox.AcceptRole))
deleteButton.click()
QTimer.singleShot(1, clickOk)
btn.click()
# This is the important check that the feature is deleted
self.assertEqual(0, len([f for f in self.vl_b.getFeatures()]))
# This is actually more checking that the database on delete action is properly set on the relation
self.assertEqual(0, len([f for f in self.vl_link.getFeatures()]))
self.assertEqual(self.table_view.model().rowCount(), 0)
示例2: unmodalWidget
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def unmodalWidget(objectName, repeatTimes=10, repeatInterval=500, step=0):
"""Look for a widget in the QGIS hierarchy to set it as
not modal.
If the widget is not found try agail after a "repeatInterval"
and repeat no more that "repeatTimes"
"""
if not objectName:
return
l = QgsApplication.instance().topLevelWidgets()
for d in l:
for dd in d.findChildren(QDialog):
if dd.objectName() != objectName:
continue
dd.setWindowModality(False)
return
if repeatTimes == step:
return
# if here => not found
QTimer.singleShot(repeatInterval,
lambda: unmodalWidget(objectName, repeatTimes, repeatInterval,
step + 1))
示例3: animate
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def animate(self):
if self.animating:
if self.nextStep():
QTimer.singleShot(500, self.animate)
else:
self.buttonPlay.setChecked(False)
self.animating = False
示例4: restoreGui
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def restoreGui(self):
"""Reset the GUI to its initial state."""
QTimer.singleShot(1000, lambda: self.dlg.pageBar.setValue(0))
self.dlg.printinglabel.setText('')
self.dlg.printinglabel.hide()
# Reset standardbuttons and their functions and labels
self.dlg.buttonBox.rejected.disconnect(self.stopProcessing)
self.dlg.buttonBox.rejected.connect(self.dlg.reject)
self.dlg.btnCancel.hide()
self.dlg.btnClose.show()
QApplication.restoreOverrideCursor()
self.dlg.exportButton.setEnabled(True)
self.arret = False
示例5: show_console
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def show_console():
""" called from QGIS to open the console """
global _console
if _console is None:
parent = iface.mainWindow() if iface else None
_console = PythonConsole(parent)
_console.show() # force show even if it was restored as hidden
# set focus to the console so the user can start typing
# defer the set focus event so it works also whether the console not visible yet
QTimer.singleShot(0, _console.activate)
else:
_console.setVisible(not _console.isVisible())
# set focus to the console so the user can start typing
if _console.isVisible():
_console.activate()
return _console
示例6: highlight
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def highlight(self, point):
currExt = self.canvas.extent()
leftPt = QgsPoint(currExt.xMinimum(), point.y())
rightPt = QgsPoint(currExt.xMaximum(), point.y())
topPt = QgsPoint(point.x(), currExt.yMaximum())
bottomPt = QgsPoint(point.x(), currExt.yMinimum())
horizLine = QgsGeometry.fromPolyline( [ leftPt , rightPt ] )
vertLine = QgsGeometry.fromPolyline( [ topPt , bottomPt ] )
self.crossRb.reset(QgsWkbTypes.LineGeometry)
self.crossRb.addGeometry(horizLine, None)
self.crossRb.addGeometry(vertLine, None)
QTimer.singleShot(700, self.resetRubberbands)
示例7: loadPreview
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def loadPreview(self, item):
if item == self.item and not self.dirty:
return
if item is None:
return
self._clear()
if isinstance(item, Table) and item.type in [Table.VectorType, Table.RasterType]:
# update the preview, but first let the manager chance to show the canvas
def runPrev():
return self._loadTablePreview(item)
QTimer.singleShot(50, runPrev)
else:
return
self.item = item
self.item.aboutToChange.connect(self.setDirty)
示例8: show_console
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def show_console():
""" called from QGIS to open the console """
global _console
if _console is None:
parent = iface.mainWindow() if iface else None
_console = PythonConsole(parent)
_console.show() # force show even if it was restored as hidden
# set focus to the console so the user can start typing
# defer the set focus event so it works also whether the console not visible yet
QTimer.singleShot(0, _console.activate)
else:
_console.setVisible(not _console.isVisible())
# set focus to the console so the user can start typing
if _console.isVisible():
_console.activate()
## Shows help on first launch of the console
settings = QSettings()
if settings.value('pythonConsole/contextHelpOnFirstLaunch', True, type=bool):
QgsContextHelp.run("PythonConsole")
settings.setValue('pythonConsole/contextHelpOnFirstLaunch', False)
return _console
示例9: _dropEvent
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def _dropEvent(event):
def alg_dropped(algorithm_id, pos):
alg = QgsApplication.processingRegistry().createAlgorithmById(algorithm_id)
if alg is not None:
self._addAlgorithm(alg, pos)
else:
assert False, algorithm_id
def input_dropped(id, pos):
if id in [param.id() for param in QgsApplication.instance().processingRegistry().parameterTypes()]:
self.addInputOfType(itemId, pos)
if event.mimeData().hasFormat('application/x-vnd.qgis.qgis.algorithmid'):
data = event.mimeData().data('application/x-vnd.qgis.qgis.algorithmid')
stream = QDataStream(data, QIODevice.ReadOnly)
algorithm_id = stream.readQString()
QTimer.singleShot(0, lambda id=algorithm_id, pos=self.view.mapToScene(event.pos()): alg_dropped(id, pos))
event.accept()
elif event.mimeData().hasText():
itemId = event.mimeData().text()
QTimer.singleShot(0, lambda id=itemId, pos=self.view.mapToScene(event.pos()): input_dropped(id, pos))
event.accept()
else:
event.ignore()
示例10: waitAfterRenderComplete
# 需要导入模块: from qgis.PyQt.QtCore import QTimer [as 别名]
# 或者: from qgis.PyQt.QtCore.QTimer import singleShot [as 别名]
def waitAfterRenderComplete(self, painter=None):
"""When the map canvas signals renderComplete, wait defined millisec until next animation step"""
if self.saveAnimation: # make animation/export run as fast as possible
self.playAnimation(painter)
else:
QTimer.singleShot(self.animationFrameLength, self.playAnimation)