本文整理汇总了Python中qgis.PyQt.QtCore.QTimer类的典型用法代码示例。如果您正苦于以下问题:Python QTimer类的具体用法?Python QTimer怎么用?Python QTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTimer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_delete_feature
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,代码行数:34,代码来源:test_qgsrelationeditwidget.py
示例2: animate
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,代码行数:7,代码来源:animation.py
示例3: __init__
def __init__(self, parent, context, webPage, layerType):
QObject.__init__(self, parent)
debug("OpenlayersController.__init__", 3)
self.context = context
self.layerType = layerType
self.img = QImage()
self.page = webPage
self.page.loadFinished.connect(self.pageLoaded)
# initial size for map
self.page.setViewportSize(QSize(1, 1))
self.timerMapReady = QTimer()
self.timerMapReady.setSingleShot(True)
self.timerMapReady.setInterval(20)
self.timerMapReady.timeout.connect(self.checkMapReady)
self.timer = QTimer()
self.timer.setInterval(100)
self.timer.timeout.connect(self.checkMapUpdate)
self.timerMax = QTimer()
self.timerMax.setSingleShot(True)
# TODO: different timeouts for map types
self.timerMax.setInterval(2500)
self.timerMax.timeout.connect(self.mapTimeout)
开发者ID:mapplus,项目名称:qgis-tmsforkorea-plugin,代码行数:28,代码来源:openlayers_layer.py
示例4: unmodalWidget
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,代码行数:27,代码来源:utils.py
示例5: MapCanvasEffects
class MapCanvasEffects():
def __init__(self):
self.project = QgsProject().instance()
self.canvas = QgsUtils.iface.mapCanvas()
self.timer = QTimer( self.canvas )
self.flash = None
def highlight(self, layer, geometry):
def getFlash():
h = QgsHighlight( self.canvas, geometry, layer )
h.setColor( QColor( 255, 0, 0, 255 ) )
h.setFillColor( QColor( 255, 0, 0, 100 ) )
h.setWidth( 2 )
return h
def finished():
self.timer.stop()
self.timer.timeout.disconnect( finished )
del self.flash
self.flash = getFlash()
self.timer.timeout.connect( finished )
self.timer.start( 500 ) # Milliseconds before finishing the flash
def zoom(self, layer, geometry):
def getBoudingBoxGeomCanvas():
crsLayer = layer.crs()
crsCanvas = self.project.crs()
if not crsLayer == crsCanvas:
ct = QgsCoordinateTransform( layer.crs(), self.project.crs(), self.project )
bbox = ct.transform( geometry.boundingBox() )
else:
bbox = geometry.boundingBox()
return bbox
self.canvas.setExtent( getBoudingBoxGeomCanvas() )
self.canvas.zoomByFactor( 1.05 )
self.canvas.refresh()
self.highlight( layer, geometry )
def highlightFeature(self, layer, feature):
if not feature.hasGeometry():
return
geom = feature.geometry()
self.highlight( layer, geom )
def zoomFeature(self, layer, feature):
if not feature.hasGeometry():
return
geom = feature.geometry()
self.zoom( layer, geom )
开发者ID:lmotta,项目名称:gimpselectionfeature_plugin,代码行数:51,代码来源:mapcanvaseffects.py
示例6: restoreGui
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,代码行数:16,代码来源:maps_printer.py
示例7: __init__
def __init__(self, iface):
QDockWidget.__init__(self, iface.mainWindow())
self.setupUi(self)
self.newsFrame.setVisible(False)
self.iface = iface
self.search_threads = None # []
self.extent_renderer = RubberBandResultRenderer()
self.cmbStatusFilter.addItem(self.tr('All'), STATUS_FILTER_ALL)
self.cmbStatusFilter.addItem(self.tr('Valid'), STATUS_FILTER_ONLY_WORKS)
self.cmbStatusFilter.currentIndexChanged.connect(self.start_search)
if hasattr(self.txtSearch, 'setPlaceholderText'):
self.txtSearch.setPlaceholderText(self.tr("Search string..."))
self.delay_timer = QTimer(self)
self.delay_timer.setSingleShot(True)
self.delay_timer.setInterval(250)
self.delay_timer.timeout.connect(self.start_search)
self.txtSearch.textChanged.connect(self.delay_timer.start)
self.btnFilterByExtent.toggled.connect(self.toggle_filter_button)
self.one_process_work = QMutex()
self.add_last_used_services()
self.show_news()
开发者ID:nextgis,项目名称:quickmapservices,代码行数:28,代码来源:qms_service_toolbox.py
示例8: fetchFiles
def fetchFiles(self, urls):
self.logT("TileLayer.fetchFiles() starts")
# create a QEventLoop object that belongs to the current thread (if ver. > 2.1, it is render thread)
eventLoop = QEventLoop()
self.logT("Create event loop: " + str(eventLoop)) # DEBUG
# QObject.connect(self, SIGNAL("allRepliesFinished()"), eventLoop.quit)
self.allRepliesFinished.connect(eventLoop.quit)
# create a timer to watch whether rendering is stopped
watchTimer = QTimer()
watchTimer.timeout.connect(eventLoop.quit)
# send a fetch request to the main thread
# self.emit(SIGNAL("fetchRequest(QStringList)"), urls)
self.fetchRequest.emit(urls)
# wait for the fetch to finish
tick = 0
interval = 500
timeoutTick = self.downloadTimeout / interval
watchTimer.start(interval)
while tick < timeoutTick:
# run event loop for 0.5 seconds at maximum
eventLoop.exec_()
if debug_mode:
qDebug("watchTimerTick: %d" % tick)
qDebug("unfinished downloads: %d" % self.downloader.unfinishedCount())
if self.downloader.unfinishedCount() == 0 or self.renderContext.renderingStopped():
break
tick += 1
watchTimer.stop()
if tick == timeoutTick and self.downloader.unfinishedCount() > 0:
self.log("fetchFiles timeout")
# self.emitShowBarMessage("fetchFiles timeout", duration=5) #DEBUG
self.downloader.abort()
self.downloader.errorStatus = Downloader.TIMEOUT_ERROR
files = self.downloader.fetchedFiles
watchTimer.timeout.disconnect(eventLoop.quit) #
# QObject.disconnect(self, SIGNAL("allRepliesFinished()"), eventLoop.quit)
self.allRepliesFinished.disconnect(eventLoop.quit)
self.logT("TileLayer.fetchFiles() ends")
return files
开发者ID:nextgis,项目名称:quickmapservices,代码行数:47,代码来源:tilelayer.py
示例9: show_console
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,代码行数:17,代码来源:console.py
示例10: highlight
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,代码行数:17,代码来源:latLonTools.py
示例11: test_link_feature
def test_link_feature(self):
"""
Check if an existing feature can be linked
"""
wrapper = self.createWrapper(self.vl_a, '"name"=\'Douglas Adams\'') # NOQA
f = QgsFeature(self.vl_b.fields())
f.setAttributes([self.vl_b.dataProvider().defaultValueClause(0), 'The Hitchhiker\'s Guide to the Galaxy'])
self.vl_b.addFeature(f)
def choose_linked_feature():
dlg = QApplication.activeModalWidget()
dlg.setSelectedFeatures([f.id()])
dlg.accept()
btn = self.widget.findChild(QToolButton, 'mLinkFeatureButton')
timer = QTimer()
timer.setSingleShot(True)
timer.setInterval(0) # will run in the event loop as soon as it's processed when the dialog is opened
timer.timeout.connect(choose_linked_feature)
timer.start()
btn.click()
# magically the above code selects the feature here...
link_feature = next(self.vl_link.getFeatures(QgsFeatureRequest().setFilterExpression('"fk_book"={}'.format(f[0]))))
self.assertIsNotNone(link_feature[0])
self.assertEqual(self.table_view.model().rowCount(), 1)
开发者ID:elpaso,项目名称:QGIS,代码行数:30,代码来源:test_qgsrelationeditwidget.py
示例12: __init__
def __init__(self, iface, model):
"""Initialize the GUI control"""
QObject.__init__(self)
self.iface = iface
self.model = model
self.optionsDialog = None
self.path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ui')
# load the form
self.dock = uic.loadUi(os.path.join(self.path, DOCK_WIDGET_FILE))
self.iface.addDockWidget(Qt.BottomDockWidgetArea, self.dock)
self.dock.pushButtonExportVideo.setEnabled(False) # only enabled if there are managed layers
self.dock.pushButtonOptions.clicked.connect(self.optionsClicked)
self.dock.pushButtonExportVideo.clicked.connect(self.exportVideoClicked)
self.dock.pushButtonToggleTime.clicked.connect(self.toggleTimeClicked)
self.dock.pushButtonArchaeology.clicked.connect(self.archaeologyClicked)
self.dock.pushButtonBack.clicked.connect(self.backClicked)
self.dock.pushButtonForward.clicked.connect(self.forwardClicked)
self.dock.pushButtonPlay.clicked.connect(self.playClicked)
self.dock.dateTimeEditCurrentTime.dateTimeChanged.connect(self.currentTimeChangedDateText)
# self.dock.horizontalTimeSlider.valueChanged.connect(self.currentTimeChangedSlider)
self.sliderTimer = QTimer(self)
self.sliderTimer.setInterval(250)
self.sliderTimer.setSingleShot(True)
self.sliderTimer.timeout.connect(self.currentTimeChangedSlider)
self.dock.horizontalTimeSlider.valueChanged.connect(self.startTimer)
self.dock.comboBoxTimeExtent.currentIndexChanged[str].connect(self.currentTimeFrameTypeChanged)
self.dock.spinBoxTimeExtent.valueChanged.connect(self.currentTimeFrameSizeChanged)
# this signal is responsible for rendering the label
self.iface.mapCanvas().renderComplete.connect(self.renderLabel)
# create shortcuts
self.focusSC = QShortcut(QKeySequence("Ctrl+Space"), self.dock)
self.focusSC.activated.connect(self.dock.horizontalTimeSlider.setFocus)
# put default values
self.dock.horizontalTimeSlider.setMinimum(conf.MIN_TIMESLIDER_DEFAULT)
self.dock.horizontalTimeSlider.setMaximum(conf.MAX_TIMESLIDER_DEFAULT)
self.dock.dateTimeEditCurrentTime.setMinimumDate(MIN_QDATE)
self.showLabel = conf.DEFAULT_SHOW_LABEL
self.exportEmpty = conf.DEFAULT_EXPORT_EMPTY
self.labelOptions = TimestampLabelConfig(self.model)
# placeholders for widgets that are added dynamically
self.bcdateSpinBox = None
# add to plugins toolbar
try:
self.action = QAction(QCoreApplication.translate("TimeManagerGuiControl", "Toggle visibility"), self.iface.mainWindow())
self.action.triggered.connect(self.toggleDock)
self.iface.addPluginToMenu(QCoreApplication.translate("TimeManagerGuiControl", "&TimeManager"), self.action)
except Exception as e:
pass # OK for testing
开发者ID:anitagraser,项目名称:TimeManager,代码行数:57,代码来源:timemanagerguicontrol.py
示例13: loadPreview
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,代码行数:19,代码来源:layer_preview.py
示例14: __init
def __init(self):
self.checkBoxHideCross.setEnabled(False)
self.__populateTypeMapGUI()
self.__populateButtonBox()
self.__registerObjJS()
self.lbStatusRead.setVisible(False)
self.__setConnections()
self.__timerMapReady = QTimer()
self.__timerMapReady.setSingleShot(True)
self.__timerMapReady.setInterval(20)
self.__timerMapReady.timeout.connect(self.__checkMapReady)
开发者ID:dongikjang,项目名称:qgis-tmsforkorea-plugin,代码行数:12,代码来源:openlayers_ovwidget.py
示例15: __init__
def __init__(self):
super(TesterWidget, self).__init__()
self.setupUi(self)
self.setObjectName("TesterPluginPanel")
self.btnCancel.clicked.connect(self.cancelTesting)
self.btnTestOk.clicked.connect(self.testPasses)
self.btnTestFailed.clicked.connect(self.testFails)
self.btnSkip.clicked.connect(self.skipTest)
self.btnNextStep.clicked.connect(self.runNextStep)
self.buttons = [self.btnTestOk, self.btnTestFailed, self.btnNextStep]
self.blinkTimer = QTimer()
self.blinkTimer.timeout.connect(self._blink)
开发者ID:boundlessgeo,项目名称:qgis-tester-plugin,代码行数:13,代码来源:testerwidget.py
示例16: show_console
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,代码行数:22,代码来源:console.py
示例17: render
def render(self):
""" do the rendering. This function is called in the worker thread """
debug("[WORKER THREAD] Calling request() asynchronously", 3)
QMetaObject.invokeMethod(self.controller, "request")
# setup a timer that checks whether the rendering has not been stopped
# in the meanwhile
timer = QTimer()
timer.setInterval(50)
timer.timeout.connect(self.onTimeout)
timer.start()
debug("[WORKER THREAD] Waiting for the async request to complete", 3)
self.loop = QEventLoop()
self.controller.finished.connect(self.loop.exit)
self.loop.exec_()
debug("[WORKER THREAD] Async request finished", 3)
painter = self.context.painter()
painter.drawImage(0, 0, self.controller.img)
return True
开发者ID:mapplus,项目名称:qgis-tmsforkorea-plugin,代码行数:23,代码来源:openlayers_layer.py
示例18: _dropEvent
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,代码行数:24,代码来源:ModelerDialog.py
示例19: __init__
def __init__(self, geturl_func, parseresult_func, parent = None):
QObject.__init__(self, parent)
self.geturl_func = geturl_func
self.parseresult_func = parseresult_func
self.editor = parent
self.networkManager = QNetworkAccessManager()
self.selectedObject = None
self.isUnloaded = False
self.popup = QTreeWidget(parent)
#self.popup.setColumnCount(2)
self.popup.setColumnCount(1)
self.popup.setUniformRowHeights(True)
self.popup.setRootIsDecorated(False)
self.popup.setEditTriggers(QTreeWidget.NoEditTriggers)
self.popup.setSelectionBehavior(QTreeWidget.SelectRows)
self.popup.setFrameStyle(QFrame.Box | QFrame.Plain)
self.popup.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.popup.header().hide()
self.popup.installEventFilter(self)
self.popup.setMouseTracking(True)
#self.connect(self.popup, SIGNAL("itemClicked(QTreeWidgetItem*, int)"),
# self.doneCompletion)
self.popup.itemClicked.connect( self.doneCompletion )
self.popup.setWindowFlags(Qt.Popup)
self.popup.setFocusPolicy(Qt.NoFocus)
self.popup.setFocusProxy(parent)
self.timer = QTimer(self)
self.timer.setSingleShot(True)
self.timer.setInterval(500)
#self.connect(self.timer, SIGNAL("timeout()"), self.autoSuggest)
self.timer.timeout.connect( self.autoSuggest )
#self.connect(self.editor, SIGNAL("textEdited(QString)"), self.timer, SLOT("start()"))
#self.editor.textEdited.connect( self.timer.start )
self.editor.textEdited.connect( self.timer.start )
#self.editor.textChanged.connect( self.timer.start )
#self.connect(self.networkManager, SIGNAL("finished(QNetworkReply*)"),
# self.handleNetworkData)
self.networkManager.finished.connect( self.handleNetworkData )
开发者ID:Septima,项目名称:qgis-geosearch,代码行数:47,代码来源:autosuggest.py
示例20: __init__
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.queue = []
self.requestingUrls = []
self.replies = []
self.eventLoop = QEventLoop()
self.sync = False
self.fetchedFiles = {}
self.clearCounts()
self.timer = QTimer()
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.fetchTimedOut)
# network settings
self.userAgent = "Mozilla/5.0"
self.max_connection = 4
self.default_cache_expiration = 24
self.errorStatus = Downloader.NO_ERROR
开发者ID:boundlessgeo,项目名称:qgis-baselayers-plugin,代码行数:20,代码来源:downloader.py
注:本文中的qgis.PyQt.QtCore.QTimer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论