PDA

View Full Version : Pyqt and Vizard 4? Is it compatible?


Renato Lima
07-27-2011, 06:30 PM
Can Vizard be embbeded in Pyqt? It is much more powerful than wxpython. But I have no clue as to where to start.

Has anyone ever tried doing it?

farshizzo
07-28-2011, 09:45 AM
I haven't personally tried, but I would guess that it should be possible. The concept should be the same as wxPython.

You will need to create a blank PyQT window and pass its window handle to viz.go, along with the viz.EMBEDDED flag. After that, you will just need to make sure you update the Vizard graphics loop periodically using the viz.frame() command.

farshizzo
07-28-2011, 03:43 PM
Good news! I was able to test out PyQt and get it working with Vizard. I've created a knowledge base article (http://kb.worldviz.com/articles/1666) describing how to get it working. Let me know if you have any issues.

Renato Lima
08-03-2011, 07:02 PM
THANK YOU VERY MUCH!!!

This is impressive!!!! We are going to port our code to QT. Thanks!

kovitch
10-20-2011, 08:47 AM
Hi,

I'm using the same code provided and i'm trying to accomplish something similar to this but for PySide. However, i'm having a small problem. The following line:


viz.go(viz.EMBEDDED,window=int(self.widget.winId() ))


Leads to the following error:


Traceback (most recent call last):
File "<string>", line 11, in <module>
File "F:\Docs\Vizard Scripts\PyQTMenu.py", line 107, in <module>
mainWin = MainWindow()
File "F:\Docs\Vizard Scripts\PyQTMenu.py", line 26, in __init__
viz.go(viz.EMBEDDED,window=int(self.widget.winId() ))
TypeError: int() argument must be a string or a number, not 'PyCObject


Is there a way to solve it?

Best regards,

Alex.

kovitch
10-20-2011, 08:55 AM
Solved.

For the record:


# Additional imports
from ctypes import pythonapi, c_void_pointer, py_object

# Setup arguments and return types
pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
pythonapi.PyCObject_AsVoidPtr.argtypes = [ py_object ]

# Convert PyCObject to a void pointer
hWnd = pythonapi.PyCObject_AsVoidPtr( view.winId() )

# Then use hWnd
viz.go( viz.EMBEDDED, window=int( hWnd ) )