class ComponentChanger(QObject, QQmlParserStatus):
    currentComponentChanged = Signal(QQmlComponent)

    def __init__(self):
        super(ComponentChanger, self).__init__(None)

        self._current_component = QQmlComponent()
        self._changes = []

    @Property(QQmlComponent, notify=currentComponentChanged)
    def currentComponent(self) -> QQmlComponent:
        return self._current_component

    def setCurrentComponent(self, new_current_component: QQmlComponent) -> None:
        self._current_component = new_current_component
        self.currentComponentChanged.emit(self._current_component)

    def appendChange(self, change: Change) -> None:
        change.actived.connect(lambda: self.setCurrentComponent(change.component))
        self._changes.append(change)

    def classBegin(self) -> None:
        pass

    def componentComplete(self) -> None:
        pass

    changes = ListProperty(Change, appendChange)
Пример #2
0
class PieChart(QQuickPaintedItem):
    def __init__(self, parent=None):
        QQuickPaintedItem.__init__(self, parent)
        self._name = u''
        self._slices = []

    def getName(self):
        return self._name

    def setName(self, value):
        self._name = value

    name = Property(text_type, getName, setName)

    def appendSlice(self, _slice):
        _slice.setParentItem(self)
        self._slices.append(_slice)

    slices = ListProperty(PieSlice, appendSlice)
Пример #3
0
class PieChart(QQuickItem):
    def __init__(self, parent=None):
        QQuickItem.__init__(self, parent)
        self._name = ''
        self._slices = []

    def getName(self):
        return self._name

    def setName(self, value):
        self._name = value

    name = Property(str, getName, setName)

    def appendSlice(self, _slice):
        global appendCalled
        _slice.setParentItem(self)
        self._slices.append(_slice)
        appendCalled = True

    slices = ListProperty(PieSlice, append=appendSlice)