[vtkusers] "Hello World" for QVTKWidget using PyQt and VTK in Python

Jothy jothybasu at gmail.com
Wed Nov 3 12:33:56 EDT 2010


I have attacehd the latest version (hope so!) of QVTKWidget. Add it to your
working dir and follow the tricks/steps  given below

1) In your form add a QFrame from designer where you want a QVTKWidget
(let's say the object name is qvtkWidget1)

2)Run pyuic4 to generate (Form1).ui files to (ui_Form1).py files

3) Now add the line "import QVTKWidget as QVW " in the ui_Form1.py file,
above the class definition

4) Actual trick is, replace *self. qvtkWidget1 = QFrame(parent) as
self.qvtkWidget1=QVW.QVTKRenderWindowInteractor(parent)*

5) uncomment the lines which add style/border as it would say during
run-time "no attribute found".

Hope this helps!

Jothy


On Wed, Nov 3, 2010 at 4:03 PM, Prathamesh Kulkarni <
prathameshmkulkarni at gmail.com> wrote:

> Yes, I selected "Full". I get the QVTKRenderWindowInteractor. I wanted to
> use the QVTKWidget since, I have used it earlier in my C++ projects.
> Never-the-less, is there any example demonstrating the use of
> QQVTKRenderWindowInteractor? (I am completely new to Python) Can I promote a
> QWidget to it, like I did for QVTKWidget through the Qt Designer?
>
> Thanks,
> Prathamesh
>
>
> On Wed, Nov 3, 2010 at 10:50 AM, Jothy <jothybasu at gmail.com> wrote:
>
>> If you are using python x,y you should have QVTKRenderWindowInteractor.py
>> in
>>
>> C:\Python26\Lib\site-packages\vtk\qt4
>>
>> Did you select "Full" during installation of pythonx,y?
>>
>>
>> Jothy
>>
>> On Wed, Nov 3, 2010 at 3:45 PM, Prathamesh Kulkarni <
>> prathameshmkulkarni at gmail.com> wrote:
>>
>>> I am using Python2.6 which comes with Pythonxy package. So I do not build
>>> VTK separately. It comes with Pythonxy too. Now, in the site_packages/vtk/qt
>>> I cannot find QVTKWidget. Also, in my separate build of VTK (with
>>> VTK_WRAP_PYTHON set) I do not get QVTKWidget iniside
>>> bin/wrapping/python/vtk/qt. Where can I get it from?
>>>
>>> - Prathamesh
>>>
>>>
>>> On Wed, Nov 3, 2010 at 5:18 AM, Jothy <jothybasu at gmail.com> wrote:
>>>
>>>> Which python bundle are you using and how are importing the QVTK?
>>>>
>>>> One easiest option is to add the QVTKWidget into your working directory
>>>> and import.
>>>>
>>>> Jothy
>>>>
>>>> On Wed, Nov 3, 2010 at 3:45 AM, Prathamesh Kulkarni <
>>>> prathameshmkulkarni at gmail.com> wrote:
>>>>
>>>>> Hello all,
>>>>>
>>>>> I want to create a GUI using PyQt4 and display a vtkImage inside it.
>>>>> For that, I need to embed a QVTKWidget in my GUI. However, I get
>>>>> 'ImportError: No module named qvtk' when I do import vtk.qvtk as given in
>>>>> http://vtk.1045678.n5.nabble.com/about-vtk-python-bindings-and-Qt-td2841114i20.html. I am confused about how to get started with this and did not find examples
>>>>> demonstrating this.
>>>>>
>>>>> Please point me to the steps for writing this "hello world".
>>>>>
>>>>> Thanks,
>>>>> Prathamesh
>>>>>
>>>>> _______________________________________________
>>>>> 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 VTK FAQ at:
>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101103/1b4c6ff1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QVTKWidget.py
Type: text/x-python
Size: 13382 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101103/1b4c6ff1/attachment.py>


More information about the vtkusers mailing list