edifice.CustomWidget

edifice.CustomWidget#

class edifice.CustomWidget[source]#

Bases: QtWidgetElement

Custom widgets that you can define.

Not all widgets are currently supported by Edifice. You can create your own base Qt Widget element by inheriting from QtWidgetElement directly, or more simply by overriding CustomWidget:

class MyWidgetElement(CustomWidget):
    def create_widget(self):
        # This function should return the new widget
        # (with parent set to None; Edifice will handle parenting)
        return QtWidgets.FooWidget()

    def paint(self, widget, newprops):
        # This function should update the widget
        for prop in newprops:
            if prop == "text":
                widget.setText(newprops[prop])
            elif prop == "value":
                widget.setValue(newprops[prop])

The two methods to override are create_widget, which should return the Qt widget, and paint, which takes the current widget and new props, and should update the widget according to the new props. The created widget inherits all the properties of Qt widgets, allowing the user to, for example, set the style.

Methods

__init__()

create_widget()

paint(widget, newprops)

register_ref(reference)

Registers provided Reference to this Element.

set_key(key)

Sets the key of the Element.

Attributes

children

The children of this Element.

props

The props of this Element.

underlying

The underlying QWidget, which may not exist if this Element has not rendered.