Well, that didn't work.

I guess I have figure out how to properly use pg.Qt.loadUiType().
----
Tim Williams


On Sun, Jan 31, 2021 at 10:39 AM Tim Williams <[email protected]> wrote:

> Thanks Patrick,
>
> I already have a Ui file from Designer. If I understand correctly, it
> looks like you're basically doing the reverse of what pysideuic does, that
> is to take a .py file and create al .ui and then do a loadUiType().
> Your <customwidgets> section did prompt me to look at that section in my
> Ui file.
>
>  <customwidgets>
>   <customwidget>
>    <class>LayoutWidget</class>
>    <extends>QWidget</extends>
>    <header>pyqtgraph</header>
>    <container>1</container>
>   </customwidget>
>  </customwidgets>
>
> I noticed that the Designer showed my ParameterTree as unused. (I'm not
> sure where that came from.I edited that file, then used Git to get it back
> to before I edited it, and Designer is not showing that message anymore)
> My ParameterTree is actually added in to my main to a Layout from another
> Ui file that does have ParameterTree as a promoted widget.
>
> (in parametertreeDialog.ui:)
>  <customwidgets>
>   <customwidget>
>    <class>ParameterTree</class>
>    <extends>QTreeWidget</extends>
>    <header>pyqtgraph.parametertree</header>
>   </customwidget>
>  </customwidgets>
>
> This is part of a QDialog that I pop up when I want to change or view the
> parameters.  I think I need to add
>   <customwidget>
>    <class>ParameterTree</class>
>    <extends>QTreeWidget</extends>
>    <header>pyqtgraph.parametertree</header>
>   </customwidget>
>
> to my main Ui file even though the widget
>
> I do use pyqtgraph.Qt.loadUiType for the MainWindow like in the
> designerExample.py example, but I would like to use uic.loadUi(),
> loader.load() for my other Ui files. I'm trying to avoid creating *.py
> files using pysideuic.
> I'm going to try adding in ParameterTree as a promoted widget and see what
> happens.
>
> ----
> Tim Williams
>
>
> On Sun, Jan 31, 2021 at 6:12 AM Patrick <[email protected]> wrote:
>
>> Hi,
>>
>> I'm not sure if this will help you, but I've been using PySide2 for one
>> of my latest projects and I remember having all sorts of issues getting .ui
>> to load, as the uic.loadUi() method I used to use for PyQt5 didn't directly
>> translate. It turns out PySide2 only fairly recently implemented the
>> PySide2.QtUiTools.loadUiType() method which was the only way I got it to
>> work, but it wasn't (isn't?) documented. I believe it should also work
>> using PyQt5.uic.loadUiType(), though haven't tried it. My UI classes look
>> something like:
>>
>> # ...
>> from PySide2 import QtCore, QtGui, QtWidgets
>> from PySide2.QtUiTools import loadUiType
>> # ...
>>
>> class DataPanel(QtWidgets.QWidget, loadUiType(__file__.split(".py")[0] +
>> ".ui")[0]):
>>
>>     def __init__(self, parent=None):
>>         super().__init__(parent)
>>         self.setupUi(self)
>>         # ...
>>
>> # ...
>>
>> The .ui file is created as normal (named the same as the python file but
>> with .ui extension), with the GraphicsLayoutWidget extended from
>> QGraphicsView as described in the pyqtgraph documentation. The relevant
>> section in the .ui XML then looks like:
>>
>>  <customwidgets>
>>   <customwidget>
>>    <class>GraphicsLayoutWidget</class>
>>    <extends>QGraphicsView</extends>
>>    <header>mypackage.pyqtgraph</header>
>>   </customwidget>
>>  </customwidgets>
>>
>> where "mypackage" is my application package name, and I have pyqtgraph in
>> a directory under it as a subpackage. If you are using a system
>> installation of pyqtgraph, then the header field should just be "pyqtgraph".
>>
>> Hopefully that might give you some ideas anyway.
>>
>> Patrick
>>
>>
>>
>> On Saturday, 30 January 2021 at 11:13:33 am UTC+10:30 [email protected]
>> wrote:
>>
>>> As a follow-up, I'm using registerCustomWidget for the promoted widgets:
>>>
>>> loader = QUiLoader()
>>> loader.registerCustomWidget(pg.GraphicsLayoutWidget)
>>> loader.registerCustomWidget(pg.widgets.TreeWidget)
>>> loader.registerCustomWidget(pg.parametertree.ParameterTree)
>>>
>>>
>>> ----
>>> Tim Williams
>>>
>>>
>>> On Fri, Jan 29, 2021 at 7:29 PM [email protected] <[email protected]>
>>> wrote:
>>>
>>>> HI,
>>>>
>>>> (Sorry about the formatting - not used to google groups posting.)
>>>>
>>>> I have an application I'm trying to get working with PySide2. I made
>>>> changes following the example designerExample.py .
>>>> <https://github.com/pyqtgraph/pyqtgraph/blob/master/examples/designerExample.py>
>>>> Everything seems to work fine with PyQt5, but when I try to use PySide
>>>> everytime I try to do a ParameterTree.setParmeters() I get an error like
>>>> this:
>>>>
>>>>   File
>>>> "C:\Users\Tim\pyside2_env\lib\site-packages\pyqtgraph\parametertree\ParameterTree.py",
>>>> line 48, in setParameters
>>>>     self.clear()
>>>>   File
>>>> "C:\Users\Tim\pyside2_env\lib\site-packages\pyqtgraph\parametertree\ParameterTree.py",
>>>> line 85, in clear
>>>>     self.invisibleRootItem().takeChildren()
>>>>   File
>>>> "C:\Users\Tim\pyside2_env\lib\site-packages\pyqtgraph\widgets\TreeWidget.py",
>>>> line 390, in takeChildren
>>>>     childs = self._real_item.takeChildren()
>>>> RuntimeError: Internal C++ object (PySide2.QtWidgets.QTreeWidgetItem)
>>>> already deleted.
>>>>
>>>> I'm using PySide2.QUiTools.QuiLoader().load to load my UI file for
>>>> PySide2, and
>>>> uic.loadUI for PyQt5.
>>>>
>>>> with importlib.resources.path('nvfieldcap.resources.ui',
>>>> 'paramtreeDialog.ui') as uifilename:
>>>> if 'PySide2' in sys.modules:
>>>> self.dialog = loader.load(uifilename.as_posix())
>>>> if 'PyQt5' in sys.modules:
>>>> self.dialog = QtWidgets.QDialog()
>>>> uic.loadUi(uifilename.as_posix(), self.dialog)
>>>>
>>>> --
>>>> 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
>>>> [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/pyqtgraph/f04abdf3-068a-41c4-a993-6076713ca61an%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/pyqtgraph/f04abdf3-068a-41c4-a993-6076713ca61an%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> 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
>> [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pyqtgraph/106f2150-1724-4402-8e29-bd3cd30bd0fbn%40googlegroups.com
>> <https://groups.google.com/d/msgid/pyqtgraph/106f2150-1724-4402-8e29-bd3cd30bd0fbn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/CAO39LaQ%3DHd0TciiRkdiQ%2BaDax9h0gcyOFAMm4irKNiPWF-kS6w%40mail.gmail.com.

Reply via email to