I hope you could assist with the following challenge:
We have conjured a small xml/C++ plugin with custom QT widgets and not all of them are represented in the XML file. Now we would like to manipulate the widget values via a python script, similar to how “trace” and “paraview.simple” would do it.
Could you give some directions on how such PV-friendly python bindings could be implemented?
Our success with Q_PROPERTY was somewhat limited, hence I ask for assistance once again.
To recap, we have a C++ plugin with internal variables A, B, where A is a float and B is a string. We would like to set these variables within ParaView’s python console as
plugin.A = 2.5
plugin.B = "string"
Currently, the connection to python is done via this construct
which enables the above python calls. However, the Q_PROPERTY approach turned out to have a notable flaw, namely QList<QVariance> in C++ translates into python as list of floatsonly, although QVariance can contain numbers, strings and more.
Is there any other approach to connect C++ plugin to a python console in ParaView? Is the Q_PROPERTY approach not meant to be used this way in the first place?
Any expertise on the matter is appreciated. Many thanks,
Art
When updated from a python console as plugin.values = [1, 3.5], the (correct) output is
values[0] = 1
values[1] = 3.5
But this update plugin.values = [1, 'a'] (with a char/string) raises an error:
../paraview/servermanager.py", line 820, in SetData
self.SMProperty.SetElement(idx, val)
TypeError: SetElement argument 2:
which, if I understand correctly is an index error. Yet, the number of elements in the array is the same. I can’t figure out what I’m doing wrong here.