Пример #1
0
    def createWidget(self, className, parent=None, name=""):
        if parent is None and self.base_instance:
            # No parent, this is the top-level widget
            return self.base_instance

        if className in QUiLoader.availableWidgets(self):
            widget = super().createWidget(className, parent, name)
        else:
            if className in self.custom_widgets:
                widget = self.custom_widgets[className].create(parent)
            else:
                raise KeyError("Unknown widget '%s'" % className)

        if self.base_instance:
            # Set an attribute for the new child widget on the base instance
            setattr(self.base_instance, name, widget)

        return widget