I made a simple ui file in QT designer that holds a graphics view widget, promoted to a pyqtgraph PlotWidget, as per instructions at the pyqtgraph site.
I converted this .ui file to .py file using pyuic4.
I wrote the code below to launch the interface with the embedded pyqtgraph widget.
from PyQt4 import QtGui
import pyqtgraph as pg
from TestUi import Ui_MainWindow
class dlgTest(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self,parent)
self.ui=Ui_MainWindow()
self.ui.setupUi(self)
wp=self.ui.wPlot #This is the pyqtgraph widget.
if __name__ == "__main__":
app=QtGui.QApplication([])
myapp=dlgTest()
myapp.show()
app.exec_()
This seems to work fine.
My problem arises from trying to do the exact same thing using PySide instead of PyQt4.
In an attempt to do this I changed first line of code above to read 'from PySide import QtGui'.
Then I used pySide-uic to create TestUi.py.
This program now fails during initialization of the graphics view widget, seemingly because thi __init__ function for the widget expected a Qwidget as input, and instead got an object of type pyside.qtgui.gwidget.
What am I missing here? I realize it's probably a simple question, but would really appreciate it if somebody could point me in the right direction.
Thanks!
J...
full error for PySide version of the above code is below:
Traceback (most recent call last):
File "D:\Python Projects\Learn pyqtgraph\main.py", line 22, in <module>
myapp=dlgTest()
File "D:\Python Projects\Learn pyqtgraph\main.py", line 17, in __init__
self.ui.setupUi(self)
File "D:\Python Projects\Learn pyqtgraph\\TestUi.py", line 21, in setupUi
self.wPlot = PlotWidget(self.centralwidget)
File "C:\Apps\WinPython-32bit-2.7.5.3\python-2.7.5\lib\site-packages\pyqtgraph\widgets\PlotWidget.py", line 48, in __init__
GraphicsView.__init__(self, parent, background=background)
File "C:\Apps\WinPython-32bit-2.7.5.3\python-2.7.5\lib\site-packages\pyqtgraph\widgets\GraphicsView.py", line 73, in __init__
QtGui.QGraphicsView.__init__(self, parent)
TypeError: arguments did not match any overloaded call:
QGraphicsView(QWidget parent=None): argument 1 has unexpected type 'PySide.QtGui.QWidget'
QGraphicsView(QGraphicsScene, QWidget parent=None): argument 1 has unexpected type 'PySide.QtGui.QWidget'