<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>It would be nice if there were such a thing on <a href="http://qt-project.org/wiki/PySide_Binaries_MacOSX">http://qt-project.org/wiki/PySide_Binaries_MacOSX</a></div><div>The Windows page has had one for a while.</div><div>Surely someone has built a binary -- yes?</div><div><br></div><div><div>On Dec 14, 2013, at 6:00 AM, <a href="mailto:pyside-request@qt-project.org">pyside-request@qt-project.org</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Send PySide mailing list submissions to<br><span class="Apple-tab-span" style="white-space:pre">       </span><a href="mailto:pyside@qt-project.org">pyside@qt-project.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br><span class="Apple-tab-span" style="white-space:pre">       </span><a href="http://lists.qt-project.org/mailman/listinfo/pyside">http://lists.qt-project.org/mailman/listinfo/pyside</a><br>or, via email, send a message with subject or body 'help' to<br><span class="Apple-tab-span" style="white-space:pre"> </span><a href="mailto:pyside-request@qt-project.org">pyside-request@qt-project.org</a><br><br>You can reach the person managing the list at<br><span class="Apple-tab-span" style="white-space:pre">   </span>pyside-owner@qt-project.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of PySide digest..."<br>Today's Topics:<br><br>   1. Re: Binding C++/VTK code using Shiboken (Nicolas SAUBAT)<br>   2. Re: Binding C++/VTK code using Shiboken (Matthew Woehlke)<br><br><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>From: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Nicolas SAUBAT <nicolas.saubat@imag.fr><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>Subject: </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Re: [PySide] Binding C++/VTK code using Shiboken</b><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>Date: </b></span><span style="font-family:'Helvetica'; font-size:medium;">December 13, 2013 12:18:44 PM EST<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">pyside@qt-project.org<br></span></div><br><br>Hi Matthew,<br><br>Thanks a lot for your answer !<br><br>So if I understand correctly (as I'm still a beginner in the Python binding world / Shiboken).<br>If I have a C++ class based on both Qt and VTK (like this one : http://camitk.imag.fr/apidocumentation/3.2/classcamitk_1_1RendererWidget.html), I would be able to expose the VTK part using VTK's Python binder OR Qt part using Shiboken, but not both (or I send $$ to VTK to convert them to Shiboken ;-) And then the solution seems to be to still use Shiboken, and inject code in the wrapped classes (containing CPython code) in order to tell it how to convert the Python object (PyObject) into a VTKObject when necessary. Which seems difficult, from the C++ side, regarding how VTK handles its VTKObjects.<br>Please let me know if I've misunderstood some points !<br><br>And, by the way, would this problem still occur if we decide not to expose to Python the VTK part ?<br>I mean, we still consider C++ classes based on both Qt and VTK, but only describe in the typesystem.xml files for Shiboken, the C++ and Qt objects we want to expose (thus no rules for VTK objects).<br>This way, the CPython extension generated would still be able to run the VTK methods trought the C++ library,  but forbid to directly handle the VTK objects from the Python world (or crashes).<br>But I don't know if it would be possible to render the 3D of VTK in some Qt widget ...<br><br>Feel free to react, as I said I'm not an expert, any advice is welcome (except sending too much $$ to kitware ;-) )<br><br>Thanks,<br>Nicolas.<br><br><br>On 12/12/2013 06:07 PM, Matthew Woehlke wrote:<br><blockquote type="cite">On 2013-12-12 11:09, Nicolas SAUBAT wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite">I'm trying to bind to Python a C++ framework, called CamiTK<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(http://camitk.imag.fr) which is based on Qt and VTK (http://www.vtk.org/).<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">For binding Qt C++ classes, no problem, we can tell Shiboken how to use<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Qt in Python, thanks to the provided typesystem.xml files.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">But I was wondering, how we can do the same stuff using VTK ?<br></blockquote></blockquote><blockquote type="cite">Well. That's a good question.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">If you just want to generate bindings for VTK-based objects, VTK has its<br></blockquote><blockquote type="cite">own wrapping system that will allow you to do that. (IME it's rather<br></blockquote><blockquote type="cite">limited compared to Shiboken; no support for enums, STL containers,<br></blockquote><blockquote type="cite">etc.) However, getting the two to talk to each other is likely to be an<br></blockquote><blockquote type="cite">issue.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">What you would ultimately need to do, I think, is to be able to teach<br></blockquote><blockquote type="cite">Shiboken how to get a vtkObject* from a PyObject. As far as the Shiboken<br></blockquote><blockquote type="cite">architecture, I think you should be able to write custom converters for<br></blockquote><blockquote type="cite">this.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The problem comes with how VTK implements its conversions, which depends<br></blockquote><blockquote type="cite">on having a pointer to the call arguments, which is not available in<br></blockquote><blockquote type="cite">Shiboken. As such, I'm not sure that (at the C++ level) it is possible<br></blockquote><blockquote type="cite">to get the vtkObject* from *just* a PyObject.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">TBH, I have the same problem and haven't solved it, except that I<br></blockquote><blockquote type="cite">decided the best thing to do would be to rewrite VTK's wrapping to just<br></blockquote><blockquote type="cite">use Shiboken and be done with it ;-). If you find a solution, please let<br></blockquote><blockquote type="cite">me know. (If you can throw $$ at making VTK use Shiboken, please also<br></blockquote><blockquote type="cite">let me know ;-).)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Note that it's probably impossible to wrap a VTK-derived object with<br></blockquote><blockquote type="cite">Shiboken in any useful way.<br></blockquote><blockquote type="cite"><br></blockquote><br>-- <br>Nicolas SAUBAT<br>Ingénieur Recherche et Développement<br>Equipe GMCAO - Laboratoire TIMC-IMAG<br>Pavillon Taillefer<br>Allée des Alpes - Domaine de la Merci<br>38706 La Tronche<br>Tel : (33)04 56 52 00 10<br><br><br><br><br><br><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>From: </b></span><span style="font-family:'Helvetica'; font-size:medium;">Matthew Woehlke <matthew.woehlke@kitware.com><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>Subject: </b></span><span style="font-family:'Helvetica'; font-size:medium;"><b>Re: [PySide] Binding C++/VTK code using Shiboken</b><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>Date: </b></span><span style="font-family:'Helvetica'; font-size:medium;">December 13, 2013 12:43:13 PM EST<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family:'Helvetica'; font-size:medium; color:rgba(127, 127, 127, 1.0);"><b>To: </b></span><span style="font-family:'Helvetica'; font-size:medium;">pyside@qt-project.org<br></span></div><br><br>On 2013-12-13 12:18, Nicolas SAUBAT wrote:<br><blockquote type="cite">If I have a C++ class based on both Qt and VTK (like this one :<br></blockquote><blockquote type="cite">http://camitk.imag.fr/apidocumentation/3.2/classcamitk_1_1RendererWidget.html),<br></blockquote><blockquote type="cite">I would be able to expose the VTK part using VTK's Python binder OR Qt<br></blockquote><blockquote type="cite">part using Shiboken, but not both.<br></blockquote><br>*AFAIK* this is correct. At least, I know that I've run into the same problem and didn't come up with a solution.<br><br><blockquote type="cite">And then the solution seems to be to still use Shiboken,<br></blockquote><blockquote type="cite">and inject code in the wrapped classes (containing CPython code) in<br></blockquote><blockquote type="cite">order to tell it how to convert the Python object (PyObject) into a<br></blockquote><blockquote type="cite">VTKObject when necessary. Which seems difficult, from the C++ side,<br></blockquote><blockquote type="cite">regarding how VTK handles its VTKObjects.<br></blockquote><blockquote type="cite">Please let me know if I've misunderstood some points !<br></blockquote><br>No, that sounds about right.<br><br>That said, maybe someone that knows VTK better would have an idea. Have you asked on the VTK list?<br><br><blockquote type="cite">And, by the way, would this problem still occur if we decide not to<br></blockquote><blockquote type="cite">expose to Python the VTK part ?<br></blockquote><br>You can wrap many things in Shiboken. If what you wrap uses Qt classes (and you are using PySide), then you will be able to wrangle those types between C++ and Python (which is really a glorified way of saying you can wrap a method that either takes or returns a Qt type). Where you'll run into trouble (using Shiboken to do the wrapping) is methods that take or return VTK object types. (POD's are not a problem in either case, of course.) Basically, if the API only wraps types that are themselves wrapped by Shiboken, you'll be fine. (Note however that you'll lose base class methods if your base class is not shiboken wrapped.)<br><br>You could, conceivably, write your own external shiboken-based Python bindings for VTK :-). (After all, PySide is separate from / 'on top of' Qt; no need to be tightly integrated into the VTK repo / build system.)<br><br>Similarly if you use VTK to do the wrapping, VTK types will be okay but Qt types will be a problem. (Also VTK's binding system has other limitations, e.g. no STL classes, very poor support for enums...)<br><br><blockquote type="cite">This way, the CPython extension generated would still be able to run the<br></blockquote><blockquote type="cite">VTK methods trought the C++ library,  but forbid to directly handle the<br></blockquote><blockquote type="cite">VTK objects from the Python world (or crashes).<br></blockquote><br>More likely Python just won't "see" methods that deal with VTK objects.<br><br><blockquote type="cite">But I don't know if it would be possible to render the 3D of VTK in some<br></blockquote><blockquote type="cite">Qt widget ...<br></blockquote><br>Hmm... I don't think QVTKWidget is a vtkObject(?); you could write your own wrapping for that and only that with Shiboken that would at least let you create the widget from Python. Assuming you even need to do that.<br><br>-- <br>Matthew<br><br><br><br><br>_______________________________________________<br>PySide mailing list<br>PySide@qt-project.org<br>http://lists.qt-project.org/mailman/listinfo/pyside<br></blockquote></div><br></body></html>