loader = QUiLoader()
loader.registerCustomWidget(pg.GraphicsLayoutWidget)
loader.registerCustomWidget(pg.widgets.TreeWidget)
loader.registerCustomWidget(pg.parametertree.ParameterTree)
--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/uv2uyQCu9MM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/f04abdf3-068a-41c4-a993-6076713ca61an%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/106f2150-1724-4402-8e29-bd3cd30bd0fbn%40googlegroups.com.
It could be that with this code:Template, BaseClass = pg.Qt.loadUiType(uifilename.as_posix())
self.FileNamingWidget = Template()
widget = BaseClass()
self.FileNamingWidget.setupUi(widget)then "self.FileNamingWidget" and "widget" are different objects, while defining a new class with:class DataPanel(QtWidgets.QWidget, loadUiType(__file__.split(".py")[0] + ".ui")[0]):then an instance of DataPanel is both a subclass of QWidget *and* whatever loadUiType()[0] returns through multiple inheritance. The type returned by the loadUiType(...)[0] magic lets the QWidget use the setupUi() method as if it were "derived from user interface descriptions created using uic" as described in the QWidget.setupUi() method documentation.
And no, I don't use the command line uic/pysideuic tools to generate python files from the .ui, I just build them in QtDesigner and use the loadUiType(...) method. If I have a subwidget which is inserted programmatically into a larger form, then I'll have a small class definition though. So something like this:from PySide2 import QtCore, QtGui, QtWidgetsfrom PySide2.QtUiTools import loadUiTypeclass MainPanel(QtWidgets.QWidget, loadUiType("mainpanel.ui")[0]):def __init__(self, parent=None):super().__init__(parent)self.setupUi(self)# ...self.subPanel = SubPanel()self.layout().addItem(self.subPanel)# ...# dynamic ui setup for SubPanelWidget, connect signals etc# ...class SubPanel(QtWidgets.QFrame, loadUiType("subpanel.ui")[0]):def __init__(self, parent=None):super().__init__(parent)self.setupUi(self)# ...# other boilerplate ui setup for SubPanelWidget
It's not as nice as being able to use the uic.load() method, but this was the first/only way I got dynamic ui loading with PySide2, so stopped messing around trying to figure out why load() was giving so much trouble.
(snip)
--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/2db65699-7066-4807-985e-d1bdec077998n%40googlegroups.com.