[Paraview] Python scripts with PyQt4

Berk Geveci berk.geveci at kitware.com
Sat Apr 17 13:39:58 EDT 2010


Hi Stefan,

I am afraid what you are trying to do is not supported. I am saying
"not supported" rather than "impossible" because someone smarter than
me may be able to figure it out. We never envisioned it as a use case.
I think you have two choices: use C++ to extend ParaView or use PyQt
from python/pvpython building the GUI from scratch. If you are
interested in the second case, I have some code that shows how to
embed the render window(s) into PyQt widgets.

-berk

On Fri, Apr 9, 2010 at 2:39 PM, Stefan Kroboth <ml at stefan-kroboth.com> wrote:
> Hello!
>
> I've build a Gui in the QtDesigner and converted it into a *.py file using pyuic4. Then I wrote a small program which loads and shows this Window. This program works fine in Python 2.6 but fails in the ParaView python shell. Since I'm new to Qt I don't know where to look for help. Is it even possible to display custom Windows?
> This is the code I tried (based on a tutorial):
>
> import sys
> from paraview.simple import *
> from PyQt4 import QtCore, QtGui
> from MITgui import Ui_MIT_Automator
>
> class Qt_MIT_Gui(QtGui.QMainWindow):
>    def __init__(self, parent=None):
>    QtGui.QWidget.__init__(self, parent)
>    self.ui = Ui_MIT_Automator()
>    self.ui.setupUi(self)
>
>
> if __name__ == "__main__":
>    bla = QtGui.QApplication(sys.argv)
>    test = Qt_MIT_Gui()
>    test.show()
>    sys.exit(test.exec_())
>
> 1. The first problem is sys.argv. I solve that by assigning ["path to the script"] to it.
> 2. When 1. is solved, it gets stuck in the line "bla = QtGui.QApplication(sys.argv)". When I comment that line, it ...
> 3. ... gets to "QtGui.QWidget.__init__(self, parent)", where it gets stuck again. ParaView just doesn't do anything and has to be killed.
>
> I tried a lot of things, which were mostly just random alterations (because of my lack of knowledge).
> It would be very nice if someone could provide me a minimal example of how to load and display a Qt gui (if this is even possible).
>
> Please excuse once again my bad englisch :)
>
> Thanks,
>   Stefan
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>


More information about the ParaView mailing list