Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from qgis.gui import QgsHighlight
- from PyQt4.QtCore import QTimer
- from PyQt4.QtGui import QColor
- timer = QTimer( iface.mapCanvas() )
- lstHighlights = []
- def flashFeatures( featureIds ):
- global lstHighlights
- for f in iface.activeLayer().getFeatures( QgsFeatureRequest().setFilterFids(featureIds) ):
- h = QgsHighlight( iface.mapCanvas(), f.geometry(), iface.activeLayer() )
- h.setColor( QColor( 255,0,0,255 ) )
- h.setWidth( 5 )
- h.setFillColor( QColor( 255,0,0,100 ) )
- lstHighlights.append( h )
- timer.start( 500 ) # Milliseconds before finishing the flash
- def finishFlash():
- timer.stop()
- global lstHighlights
- lstHighlights = []
- timer.timeout.connect( finishFlash )
- flashFeatures( iface.activeLayer().selectedFeaturesIds() )
- iface.activeLayer().selectionChanged.connect( flashFeatures )
- canvas = iface.mapCanvas()
- layer = iface.activeLayer()
- my_features_ids = [42, 43, 45]
- canvas.flashFeatureIds(layer, my_feature_ids)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement