PyQt GUI

H

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
 
D

Diez B. Roggisch

Helvin said:
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
 
P

Phil Thompson

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
 
D

Diez B. Roggisch

Phil said:
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
 
H

Helvin

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
 
R

Robert Kern

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
 
H

Helvin

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


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
 
H

Helvin

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
 
R

Robert Kern

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
 
H

Helvin

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
 
H

Helvin

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
 
R

Robert Kern

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
 
H

Helvin

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
 
R

Robert Kern

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
 
H

Helvin

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top