This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
symbol = QgsMarkerSymbolV2.createSimple({"name":"arrow"}) | |
layer = qgis.utils.iface.activeLayer() | |
layer.rendererV2().setSymbol(symbol) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Control(object): | |
def __init__(self, name="Control"): | |
self.name = name | |
self.value = None | |
def bindCheckBox(value, *args): | |
control.value = value | |
def unbindCheckBox(*args): | |
return control.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bindQTextEdit(self, value): | |
self.setText(value) | |
def unbindQTextEdit(self, **kwargs): | |
return self.toPlainText() | |
if __name__ == "__main__": | |
from PyQt4.QtGui import * | |
app = QApplication([]) | |
QTextEdit.bind = bindQTextEdit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4.QtGui import * | |
def bindQComboBox(control, value): | |
control.addItems(value) | |
control.setCurrentIndex(1) | |
def unbindQComboBox(control): | |
return control.currentText() | |
def bindQTextEdit(control, value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyFunctionClass(QgsExpressionFunction): | |
name = "AddSomeStuff" | |
args = 3 | |
group = "Math" | |
def __init__(self): | |
super(MyFunction, QgsExpressionFunction).__init__(self, name, args, group) | |
def func(values, feature, parent): | |
# blah blah blah |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QgsExpressionFunction(object): | |
def __init__(self): | |
pass | |
def func(values, feature, parent): | |
pass | |
def qgsfunction(args, group): | |
def wrapper(func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.core import QgsExpression | |
class QgsExpressionFunction(QgsExpression.FunctionDef): | |
def __init__(self, name, args, group): | |
QgsExpression.FunctionDef.__init__(self, name, args, group) | |
def func(self, values, feature, parent): | |
pass | |
def qgsfunction(args, group): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.core import QgsExpression | |
class QgsExpressionFunction(QgsExpression.FunctionDef): | |
def __init__(self, name, args, group): | |
QgsExpression.FunctionDef.__init__(self, name, args, group) | |
def func(self, values, feature, parent): | |
pass | |
def qgsfunction(args, group, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@qgsfunction(0, "Python") | |
def vertices(values, feature, parent): | |
vertices = 0 | |
geom = feature.geometry() | |
if geom is None: return 0 | |
if geom.type() == QGis.Polygon: | |
vertices = 0 | |
if geom.isMultipart(): | |
polygons = geom.asMultiPolygon() | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.core import * | |
from qgis.gui import * | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import QApplication | |
from PyQt4.QtXml import * | |
import sys | |
import xml.etree.ElementTree as ET | |
app = QApplication(sys.argv) |