PyQt GUI

Discussion in 'Python' started by Helvin, Jul 8, 2009.

  1. Helvin

    Helvin Guest

    Hi experts!

    I'm developing a GUI for a software using PyQT, and need 3D
    visualization. Should I use PyOpenGL or VTK?
    I understand that the PyQt package comes with a opengl module. What
    else would I need? I think I need to download opengl. but how? where?
    I have VTK and pyVTK installed, but I don't know how to use it in my
    code, as when I run it, an error says it can't find the vtk module.

    Help would be sooooo appreciated!
    Helvin
     
    Helvin, Jul 8, 2009
    #1
    1. Advertising

  2. Helvin wrote:

    > Hi experts!
    >
    > I'm developing a GUI for a software using PyQT, and need 3D
    > visualization. Should I use PyOpenGL or VTK?
    > I understand that the PyQt package comes with a opengl module. What
    > else would I need? I think I need to download opengl. but how? where?
    > I have VTK and pyVTK installed, but I don't know how to use it in my
    > code, as when I run it, an error says it can't find the vtk module.


    VTK won't mix with Qt. And I don't think you need to download opengl - it
    either comes with your system (or gfx-drivers), or not. I'm not sure if Qt
    actually wraps the OpenGL api itself, AFAIK it doesn't, so you need
    PyOpenGL I guess.

    Diez
     
    Diez B. Roggisch, Jul 8, 2009
    #2
    1. Advertising

  3. On Wed, 08 Jul 2009 11:11:51 +0200, "Diez B. Roggisch"
    <>
    wrote:
    > Helvin wrote:
    >
    >> Hi experts!
    >>
    >> I'm developing a GUI for a software using PyQT, and need 3D
    >> visualization. Should I use PyOpenGL or VTK?
    >> I understand that the PyQt package comes with a opengl module. What
    >> else would I need? I think I need to download opengl. but how? where?
    >> I have VTK and pyVTK installed, but I don't know how to use it in my
    >> code, as when I run it, an error says it can't find the vtk module.

    >
    > VTK won't mix with Qt. And I don't think you need to download opengl - it
    > either comes with your system (or gfx-drivers), or not. I'm not sure if

    Qt
    > actually wraps the OpenGL api itself, AFAIK it doesn't, so you need
    > PyOpenGL I guess.


    VTK has explicit support for both Qt (ie. via C++) and PyQt.

    Phil
     
    Phil Thompson, Jul 8, 2009
    #3
  4. Phil Thompson wrote:

    > On Wed, 08 Jul 2009 11:11:51 +0200, "Diez B. Roggisch"
    > <>
    > wrote:
    >> Helvin wrote:
    >>
    >>> Hi experts!
    >>>
    >>> I'm developing a GUI for a software using PyQT, and need 3D
    >>> visualization. Should I use PyOpenGL or VTK?
    >>> I understand that the PyQt package comes with a opengl module. What
    >>> else would I need? I think I need to download opengl. but how? where?
    >>> I have VTK and pyVTK installed, but I don't know how to use it in my
    >>> code, as when I run it, an error says it can't find the vtk module.

    >>
    >> VTK won't mix with Qt. And I don't think you need to download opengl - it
    >> either comes with your system (or gfx-drivers), or not. I'm not sure if

    > Qt
    >> actually wraps the OpenGL api itself, AFAIK it doesn't, so you need
    >> PyOpenGL I guess.

    >
    > VTK has explicit support for both Qt (ie. via C++) and PyQt.


    Oh, I'm sorry for the FUD - they talk about Tk on their homepage.

    Diez
     
    Diez B. Roggisch, Jul 8, 2009
    #4
  5. Helvin

    Helvin Guest

    On Jul 8, 9:23 pm, Phil Thompson <> wrote:
    > On Wed, 08 Jul 2009 11:11:51 +0200, "Diez B. Roggisch"
    > <>
    > wrote:
    >
    >
    >
    >
    >
    > > Helvin wrote:

    >
    > >> Hi experts!

    >
    > >> I'm developing a GUI for a software using PyQT, and need 3D
    > >> visualization. Should I use PyOpenGL or VTK?
    > >> I understand that the PyQt package comes with a opengl module. What
    > >> else would I need? I think I need to download opengl. but how? where?
    > >> I have VTK and pyVTK installed, but I don't know how to use it in my
    > >> code, as when I run it, an error says it can't find the vtk module.

    >
    > > VTK won't mix with Qt. And I don't think you need to download opengl - it
    > > either comes with your system (or gfx-drivers), or not. I'm not sure if

    > Qt
    > > actually wraps the OpenGL api itself, AFAIK it doesn't, so you need
    > > PyOpenGL I guess.

    >
    > VTK has explicit support for both Qt (ie. via C++) and PyQt.
    >
    > Phil


    Thanks for the fast replies! I will look into how to use VTK now.
    Where would I find VTK's explicit support for PyQt?

    Because I have installed VTK (using its installer) and pyVTK (using
    its setup.py file), but how do I actually use it in my code? According
    to: http://www.nabble.com/embedded-VTK-window-in-PyQt-application-td23521455.html,
    I have tried 'import vtk', but python can't find the vtk module.

    Thanks a million!
    Helvin
     
    Helvin, Jul 9, 2009
    #5
  6. Helvin

    Robert Kern Guest

    On 2009-07-08 18:10, Helvin wrote:

    > Thanks for the fast replies! I will look into how to use VTK now.
    > Where would I find VTK's explicit support for PyQt?


    Wrapping/Python/vtk/qt4/ in the VTK sources.

    > Because I have installed VTK (using its installer) and pyVTK (using
    > its setup.py file), but how do I actually use it in my code? According
    > to: http://www.nabble.com/embedded-VTK-window-in-PyQt-application-td23521455.html,
    > I have tried 'import vtk', but python can't find the vtk module.


    Then you have not installed VTK's Python bindings correctly. Note that pyVTK is
    just a library for manipulating VTK files. The VTK Python bindings are part of
    VTK's distribution itself. Exactly how did you install VTK? Did you compile it
    yourself?

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Jul 9, 2009
    #6
  7. I use OpenInventor (Coin3d) which have a python binding called "pivy".
    It works great.

    http://pivy.coin3d.org/

    Juan Pablo

    2009/7/8 Helvin <>:
    > Hi experts!
    >
    > I'm developing a GUI for a software using PyQT, and need 3D
    > visualization. Should I use PyOpenGL or VTK?
    > I understand that the PyQt package comes with a opengl module. What
    > else would I need? I think I need to download opengl. but how? where?
    > I have VTK and pyVTK installed, but I don't know how to use it in my
    > code, as when I run it, an error says it can't find the vtk module.
    >
    > Help would be sooooo appreciated!
    > Helvin
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
     
    Juan Pablo Romero Méndez, Jul 9, 2009
    #7
  8. Helvin

    Helvin Guest

    On Jul 9, 11:29 am, Robert Kern <> wrote:
    > On 2009-07-08 18:10, Helvin wrote:
    >
    > > Thanks for the fast replies! I will look into how to use VTK now.
    > > Where would I find VTK's explicit support for PyQt?

    >
    > Wrapping/Python/vtk/qt4/ in the VTK sources.
    >
    > > Because I have installed VTK (using its installer) and pyVTK (using
    > > its setup.py file), but how do I actually use it in my code? According
    > > to:http://www.nabble.com/embedded-VTK-window-in-PyQt-application-td23521...,
    > > I have tried 'import vtk', but python can't find the vtk module.

    >
    > Then you have not installed VTK's Python bindings correctly. Note that pyVTK is
    > just a library for manipulating VTK files. The VTK Python bindings are part of
    > VTK's distribution itself. Exactly how did you install VTK? Did you compile it
    > yourself?
    >
    > --
    > Robert Kern
    >
    > "I have come to believe that the whole world is an enigma, a harmless enigma
    >   that is made terrible by our own mad attempt to interpret it as though it had
    >   an underlying truth."
    >    -- Umberto Eco


    You mean, when I download VTK, the VTK Python bindings come with it?
    I downloaded VTK from:http://vtk.org/files/release/5.4/

    I downloaded pyVTK from: http://pypi.python.org/pypi/PyVTK/0.4.67
    And then installed it by the command 'python setup.py install'
    according to: http://cens.ioc.ee/projects/pyvtk/
    I understand that this command runs the file called 'setup.py' that
    came with the pyVTK download.

    Thanks so much for your help! I am very desperate now...

    Helvin
     
    Helvin, Jul 9, 2009
    #8
  9. Helvin

    Helvin Guest

    On Jul 9, 6:27 pm, Helvin <> wrote:
    > On Jul 9, 11:29 am, Robert Kern <> wrote:
    >
    >
    >
    >
    >
    > > On 2009-07-08 18:10, Helvin wrote:

    >
    > > > Thanks for the fast replies! I will look into how to use VTK now.
    > > > Where would I find VTK's explicit support for PyQt?

    >
    > > Wrapping/Python/vtk/qt4/ in the VTK sources.

    >
    > > > Because I have installed VTK (using its installer) and pyVTK (using
    > > > its setup.py file), but how do I actually use it in my code? According
    > > > to:http://www.nabble.com/embedded-VTK-window-in-PyQt-application-td23521...,
    > > > I have tried 'import vtk', but python can't find the vtk module.

    >
    > > Then you have not installed VTK's Python bindings correctly. Note that pyVTK is
    > > just a library for manipulating VTK files. The VTK Python bindings are part of
    > > VTK's distribution itself. Exactly how did you install VTK? Did you compile it
    > > yourself?

    >
    > > --
    > > Robert Kern

    >
    > > "I have come to believe that the whole world is an enigma, a harmless enigma
    > >   that is made terrible by our own mad attempt to interpret it as though it had
    > >   an underlying truth."
    > >    -- Umberto Eco

    >
    > You mean, when I download VTK, the VTK Python bindings come with it?
    > I downloaded VTK from:http://vtk.org/files/release/5.4/
    >
    > I downloaded pyVTK from:http://pypi.python.org/pypi/PyVTK/0.4.67
    > And then installed it by the command 'python setup.py install'
    > according to:http://cens.ioc.ee/projects/pyvtk/
    > I understand that this command runs the file called 'setup.py' that
    > came with the pyVTK download.
    >
    > Thanks so much for your help! I am very desperate now...
    >
    > Helvin


    I googled: vtk for beginners python.
    From there, I found this: http://www.nabble.com/pls-help-how-to-install-VTK-and-run-td14977428.html
    And from there, this: http://www-viz.tamu.edu/courses/viza658/08spring/tutorials/WinVTKInstall.html

    This last one has very detailed info about how to get started with
    VTK. I am now redoing the installing VTK thing. Hope it will work.

    Helvin
     
    Helvin, Jul 9, 2009
    #9
  10. Helvin

    Robert Kern Guest

    On 2009-07-09 01:27, Helvin wrote:
    > On Jul 9, 11:29 am, Robert Kern<> wrote:
    >> On 2009-07-08 18:10, Helvin wrote:
    >>
    >>> Thanks for the fast replies! I will look into how to use VTK now.
    >>> Where would I find VTK's explicit support for PyQt?

    >> Wrapping/Python/vtk/qt4/ in the VTK sources.
    >>
    >>> Because I have installed VTK (using its installer) and pyVTK (using
    >>> its setup.py file), but how do I actually use it in my code? According
    >>> to:http://www.nabble.com/embedded-VTK-window-in-PyQt-application-td23521...,
    >>> I have tried 'import vtk', but python can't find the vtk module.

    >> Then you have not installed VTK's Python bindings correctly. Note that pyVTK is
    >> just a library for manipulating VTK files. The VTK Python bindings are part of
    >> VTK's distribution itself. Exactly how did you install VTK? Did you compile it
    >> yourself?

    >
    > You mean, when I download VTK, the VTK Python bindings come with it?
    > I downloaded VTK from:http://vtk.org/files/release/5.4/


    Exactly which file did you download? I don't think the vtk-5.4.x-win32.exe
    installers have the Python bindings. You will need to build VTK from sources.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Jul 9, 2009
    #10
  11. Helvin

    Helvin Guest

    On Jul 10, 3:54 am, Robert Kern <> wrote:
    > On 2009-07-09 01:27, Helvin wrote:
    >
    >
    >
    >
    >
    > > On Jul 9, 11:29 am, Robert Kern<>  wrote:
    > >> On 2009-07-08 18:10, Helvin wrote:

    >
    > >>> Thanks for the fast replies! I will look into how to use VTK now.
    > >>> Where would I find VTK's explicit support for PyQt?
    > >> Wrapping/Python/vtk/qt4/ in the VTK sources.

    >
    > >>> Because I have installed VTK (using its installer) and pyVTK (using
    > >>> its setup.py file), but how do I actually use it in my code? According
    > >>> to:http://www.nabble.com/embedded-VTK-window-in-PyQt-application-td23521...,
    > >>> I have tried 'import vtk', but python can't find the vtk module.
    > >> Then you have not installed VTK's Python bindings correctly. Note that pyVTK is
    > >> just a library for manipulating VTK files. The VTK Python bindings are part of
    > >> VTK's distribution itself. Exactly how did you install VTK? Did you compile it
    > >> yourself?

    >
    > > You mean, when I download VTK, the VTK Python bindings come with it?
    > > I downloaded VTK from:http://vtk.org/files/release/5.4/

    >
    > Exactly which file did you download? I don't think the vtk-5.4.x-win32.exe
    > installers have the Python bindings. You will need to build VTK from sources.
    >
    > --
    > Robert Kern
    >
    > "I have come to believe that the whole world is an enigma, a harmless enigma
    >   that is made terrible by our own mad attempt to interpret it as though it had
    >   an underlying truth."
    >    -- Umberto Eco


    Yes, I think you are right. I did initially use the windows installer.
    I didn't know that it did't have python bindings. I thought that if I
    had pyVTK, then it would work. But it didn't. I am now building VTK
    with sources according to this EXCELLENT tutorial that I have somehow
    come across, at:
    http://www-viz.tamu.edu/courses/viza658/08spring/tutorials/WinVTKInstall.html

    It's for Windows XP, and I am on Vista, but I hope it will work. I
    have worked my way through most of it now.

    Thanks Robert!
    Helvin
     
    Helvin, Jul 9, 2009
    #11
  12. Helvin

    Helvin Guest

    I believe I now have vtkpython.exe. However, my 'import vtk' statement
    in my python code is not working. The error says something like "no
    module named vtk".
    Where do I find modules for vtk in pyqt? Do they exist?

    They must, right? Because there are people using vtk in pyqt? Or do I
    have to use OpenGL?

    Confused...
    Helvin
     
    Helvin, Jul 23, 2009
    #12
  13. Helvin

    Robert Kern Guest

    On 2009-07-23 03:55, Helvin wrote:
    > I believe I now have vtkpython.exe. However, my 'import vtk' statement
    > in my python code is not working. The error says something like "no
    > module named vtk".
    > Where do I find modules for vtk in pyqt? Do they exist?


    There are no VTK modules in PyQt itself. The PyQt support is in the vtk package
    which can be built with VTK itself. You will need to install VTK and the vtk
    package correctly in order to achieve this. vtkpython.exe is not going to help
    you. Ignore it. After you have built VTK, you need to do an extra step to
    install the vtk package to where your Python interpreter will be able to find it.

    Let's say that your build directory is c:\vtkbuild.

    cd \vtkbuild\Wrapping\Python
    python setup.py install
    cd \

    Now you should be able to import vtk from your normal Python interpreter. If you
    are still having problems, you will need to copy-and-paste exactly what you did
    and what error messages you got. Do not paraphrase error messages.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Jul 23, 2009
    #13
  14. Helvin

    Helvin Guest

    On Jul 24, 5:03 am, Robert Kern <> wrote:
    > On 2009-07-23 03:55, Helvin wrote:
    >
    > > I believe I now have vtkpython.exe. However, my 'import vtk' statement
    > > in my python code is not working. The error says something like "no
    > > module named vtk".
    > > Where do I find modules for vtk inpyqt? Do they exist?

    >
    > There are no VTK modules inPyQtitself. ThePyQtsupport is in the vtk package
    > which can be built with VTK itself. You will need to install VTK and the vtk
    > package correctly in order to achieve this. vtkpython.exe is not going to help
    > you. Ignore it. After you have built VTK, you need to do an extra step to
    > install the vtk package to where your Python interpreter will be able to find it.
    >
    > Let's say that your build directory is c:\vtkbuild.
    >
    >    cd \vtkbuild\Wrapping\Python
    >    python setup.py install
    >    cd \
    >
    > Now you should be able to import vtk from your normal Python interpreter. If you
    > are still having problems, you will need to copy-and-paste exactly what you did
    > and what error messages you got. Do not paraphrase error messages.
    >
    > --
    > Robert Kern
    >
    > "I have come to believe that the whole world is an enigma, a harmless enigma
    >   that is made terrible by our own mad attempt to interpret it as though it had
    >   an underlying truth."
    >    -- Umberto Eco


    Hi Robert,

    I realised that vtkpython.exe works, if I drag and drop my .py file on
    it. Ie, running my .py file using vtkpython.exe
    But my python interpreter does not work with the python file. I have
    tried what you suggested.
    Below is what I typed in command line, as well as the error that it
    produces.

    C:\Qt\VTKbin7\Wrapping\Python>python setup.py install
    Traceback (most recent call last):
    File "setup.py", line 138, in <module>
    raise "ERROR: Must specify BUILD_TYPE=<config-name> on command
    line."
    TypeError: exceptions must be classes or instances, not str

    Is it just a small error with input format or something?

    Thanks so much!
    Helvin
     
    Helvin, Jul 26, 2009
    #14
  15. Helvin

    Robert Kern Guest

    On 2009-07-26 07:04, Helvin wrote:

    > C:\Qt\VTKbin7\Wrapping\Python>python setup.py install
    > Traceback (most recent call last):
    > File "setup.py", line 138, in<module>
    > raise "ERROR: Must specify BUILD_TYPE=<config-name> on command
    > line."
    > TypeError: exceptions must be classes or instances, not str
    >
    > Is it just a small error with input format or something?


    Read the source, please:

    # The build type ('Release', 'Debug' etc.). If vtk_has_configuration_types
    # is true this must be set. It may be set on the command line by something
    # like 'BUILD_TYPE=Release'. For example::
    # python setup.py install --prefix=D:\\Python23 BUILD_TYPE=Release

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Jul 27, 2009
    #15
  16. Helvin

    Helvin Guest

    Having left my problem with this embedding vtk business for a month, I
    came back to it yesterday, and with a bit more programming knowledge,
    found that my problem was simply with the python path. All I needed to
    do was to append, in my GUI file, the path to the python bindings,
    which came with the source. I have blogged in more detail here:

    http://learnwithhelvin.blogspot.com/2009/09/embedding-vtk-into-pyqt-gui.

    My VTK stuff are now displayed in my GUI! =D
    Welcome to ask, if my blog is not detailed enough. I just wasn't
    bothered to put my entire file on there.

    Helvin
     
    Helvin, Sep 1, 2009
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ulysses
    Replies:
    5
    Views:
    382
    ulysses
    Oct 14, 2003
  2. ulysses
    Replies:
    4
    Views:
    769
    Werner Schiendl
    Oct 22, 2003
  3. =?UTF-8?B?0JTQsNC80ZjQsNC9INCT0LXQvtGA0LPQuNC10LLR

    PyQT, automatically creating GUI for configuration options

    =?UTF-8?B?0JTQsNC80ZjQsNC9INCT0LXQvtGA0LPQuNC10LLR, Jun 18, 2004, in forum: Python
    Replies:
    2
    Views:
    382
    David Fraser
    Jun 23, 2004
  4. Stelios Xanthakis

    ANN: GUI wrapper for pygtk, pyqt and wxpython

    Stelios Xanthakis, Oct 8, 2004, in forum: Python
    Replies:
    9
    Views:
    652
    Magnus Lie Hetland
    Oct 15, 2004
  5. Stelios Xanthakis
    Replies:
    0
    Views:
    397
    Stelios Xanthakis
    Oct 17, 2004
Loading...

Share This Page