diff --git a/examples/customrectitemconfig.py b/examples/customrectitemconfig.py new file mode 100644 index 0000000..0ca5c45 --- /dev/null +++ b/examples/customrectitemconfig.py @@ -0,0 +1,26 @@ +from PyQt4.QtGui import QPen +from PyQt4.Qt import Qt +from sloth.items import RectItem + + +class CustomRectItem(RectItem): + # display values of x and y as text inside the rectangle + defaultAutoTextKeys = ['x', 'y'] + + def __init__(self, *args, **kwargs): + RectItem.__init__(self, *args, **kwargs) + + # set drawing pen to red with width 2 + self.setPen(QPen(Qt.red, 2)) + +LABELS = ( + { + 'attributes': { + 'class': 'rect', + }, + 'inserter': 'sloth.items.RectItemInserter', + 'item': CustomRectItem, # use custom rect item instead of sloth's standard item + 'text': 'Rectangle', + }, +) +