当前位置: 首页>>代码示例>>Python>>正文


Python QTimer.singleShot方法代码示例

本文整理汇总了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)
开发者ID:elpaso,项目名称:QGIS,代码行数:36,代码来源:test_qgsrelationeditwidget.py

示例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))
开发者ID:gioman,项目名称:qgis-lessons-plugin,代码行数:29,代码来源:utils.py

示例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
开发者ID:boundlessgeo,项目名称:qgis-mapstory-plugin,代码行数:9,代码来源:animation.py

示例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
开发者ID:DelazJ,项目名称:MapsPrinter,代码行数:18,代码来源:maps_printer.py

示例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
开发者ID:Jacory,项目名称:QGIS,代码行数:19,代码来源:console.py

示例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)
开发者ID:NationalSecurityAgency,项目名称:qgis-latlontools-plugin,代码行数:19,代码来源:latLonTools.py

示例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)
开发者ID:Gustry,项目名称:QGIS,代码行数:21,代码来源:layer_preview.py

示例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
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:24,代码来源:console.py

示例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()
开发者ID:dwsilk,项目名称:QGIS,代码行数:26,代码来源:ModelerDialog.py

示例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)
开发者ID:anitagraser,项目名称:TimeManager,代码行数:8,代码来源:timemanagercontrol.py


注:本文中的qgis.PyQt.QtCore.QTimer.singleShot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。