[Ctk-developers] ctkMatrixWidget: setValue not invokable from Python

Julien Finet julien.finet at kitware.com
Fri Aug 19 12:37:02 EDT 2011


I guess, nothing prevent us from doing that as well.

J.

On Fri, Aug 19, 2011 at 12:29 PM, Daniel Haehn <haehn at bwh.harvard.edu>wrote:

> Maybe it would have been easier to make setValue(i,j,value) Q_INVOKABLE :)
>
> Daniel
>
> On Fri, Aug 19, 2011 at 12:22 PM, Julien Finet <julien.finet at kitware.com>
> wrote:
> > I'm a bit reluctant to make ctkMatrixWidget's code less readable just to
> > please scripting.
> > From http://pythonqt.sourceforge.net/Features.html: it seems that we
> need to
> > add our own "handlers" (whatever it means).
> > I'm not sure what it implies though.
> > Julien.
> >
> > On Fri, Aug 19, 2011 at 12:14 PM, Daniel Haehn <haehn at bwh.harvard.edu>
> > wrote:
> >>
> >> Hi Julien,
> >>
> >> I tried it but it did not change anything.. :/
> >>
> >> Daniel
> >>
> >> On Fri, Aug 19, 2011 at 12:03 PM, Julien Finet <
> julien.finet at kitware.com>
> >> wrote:
> >> > Maybe QVector<double> needs to be entered in the meta object system.
> >> > Can you try adding
> >> >
> >> > qRegisterMetaType<QVector<double> > ("QVector<double>");
> >> >
> >> > in the constructor function of ctkMatrixWidget (better: init() of
> >> > ctkMatrixWidgetPrivate if it exists)
> >> > j.
> >> > On Fri, Aug 19, 2011 at 11:55 AM, Daniel Haehn <haehn at bwh.harvard.edu
> >
> >> > wrote:
> >> >>
> >> >> Hi again,
> >> >>
> >> >> so it seems that PythonQt has problems to wrap a QVector<double>. The
> >> >> setValues method is not accesible from python and the values() method
> >> >> returns:
> >> >>
> >> >>  QVector<double> (C++ Object 0x14c479690)
> >> >>
> >> >> rather than a python list. Maybe PythonQt only supports
> >> >> QVector<double*> ?
> >> >>
> >> >> Maybe it makes more sense to return a QVariantList which maps to
> >> >> python tuples in PythonQt?
> >> >>
> >> >> What do you guys think?
> >> >>
> >> >> Thanks,
> >> >> Daniel
> >> >>
> >> >> On Wed, Aug 17, 2011 at 7:56 PM, Daniel Haehn <haehn at bwh.harvard.edu
> >
> >> >> wrote:
> >> >> > Great, thank you!
> >> >> >
> >> >> > Daniel
> >> >> >
> >> >> > On Wed, Aug 17, 2011 at 7:48 PM, Julien Finet
> >> >> > <julien.finet at kitware.com>
> >> >> > wrote:
> >> >> >> Added in CTK:
> >> >> >>
> >> >> >>
> >> >> >>
> https://github.com/commontk/CTK/commit/5ebd60003b230f961bfb5d2c89c17f0ddcb4a151
> >> >> >> Added in Slicer: r17743
> >> >> >>
> >> >> >>
> >> >> >>
> http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=17743
> >> >> >> Thanks,
> >> >> >> Julien.
> >> >> >>
> >> >> >> On Wed, Aug 17, 2011 at 4:55 PM, Daniel Haehn
> >> >> >> <haehn at bwh.harvard.edu>
> >> >> >> wrote:
> >> >> >>>
> >> >> >>> Thanks for the feedback,
> >> >> >>>
> >> >> >>> I just commited
> >> >> >>>
> >> >> >>>
> >> >> >>>
> >> >> >>>
> https://github.com/haehn/CTK/commit/583a229fce5d99f06b78bab1c3a38cfe4255a328
> >> >> >>>
> >> >> >>> Would be great if we could encounter these changes to upstream
> and
> >> >> >>> then to Slicer CTK - the EMSegmenter needs it :)
> >> >> >>>
> >> >> >>> Thx,
> >> >> >>> Daniel
> >> >> >>>
> >> >> >>> On Wed, Aug 17, 2011 at 4:48 PM, Julien Finet
> >> >> >>> <julien.finet at kitware.com>
> >> >> >>> wrote:
> >> >> >>> > Looks good, except that when populating the values vector
> >> >> >>> > (ctkMatrixWidget::values()), I would call
> >> >> >>> > ctkMatrixWidget::value(i,j)
> >> >> >>> > instead of manually querying the data in order to factorize
> code.
> >> >> >>> > Thanks,
> >> >> >>> > Julien.
> >> >> >>> > p.s.I agree that setValues() would also beneficiate from some
> >> >> >>> > refactorization as well, but it's another story...
> >> >> >>> >
> >> >> >>> > On Wed, Aug 17, 2011 at 4:15 PM, Daniel Haehn
> >> >> >>> > <haehn at bwh.harvard.edu>
> >> >> >>> > wrote:
> >> >> >>> >>
> >> >> >>> >> Hi guys,
> >> >> >>> >>
> >> >> >>> >> could you please review
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >>
> https://github.com/haehn/CTK/tree/add-SetValuesQPropertyMatrixWidget-feature
> >> >> >>> >>
> >> >> >>> >> Thx,
> >> >> >>> >> Daniel
> >> >> >>> >>
> >> >> >>> >> On Tue, Aug 16, 2011 at 3:57 PM, Jean-Christophe Fillion-Robin
> >> >> >>> >> <jchris.fillionr at kitware.com> wrote:
> >> >> >>> >> > +1 for setValues
> >> >> >>> >> > Jc
> >> >> >>> >> >
> >> >> >>> >> > On Tue, Aug 16, 2011 at 3:11 PM, Julien Finet
> >> >> >>> >> > <julien.finet at kitware.com>
> >> >> >>> >> > wrote:
> >> >> >>> >> >>
> >> >> >>> >> >> Because a "Q_PROPERTY adds features through the meta-object
> >> >> >>> >> >> system".
> >> >> >>> >> >> Practically in this case, it allows the property to be
> >> >> >>> >> >> wrapped
> >> >> >>> >> >> with
> >> >> >>> >> >> python, and initial values can also be set directly via the
> >> >> >>> >> >> Designer.
> >> >> >>> >> >> As a more philosophical point, the matrix "values" are a
> >> >> >>> >> >> "property"
> >> >> >>> >> >> of
> >> >> >>> >> >> the
> >> >> >>> >> >> matrix.
> >> >> >>> >> >> Julien.
> >> >> >>> >> >> On Tue, Aug 16, 2011 at 3:04 PM, Daniel Haehn
> >> >> >>> >> >> <haehn at bwh.harvard.edu>
> >> >> >>> >> >> wrote:
> >> >> >>> >> >>>
> >> >> >>> >> >>> Hi Julien,
> >> >> >>> >> >>>
> >> >> >>> >> >>> why do you think a Q_PROPERTY is better? Anyway, I will
> give
> >> >> >>> >> >>> it
> >> >> >>> >> >>> a
> >> >> >>> >> >>> shot
> >> >> >>> >> >>> and let you know.
> >> >> >>> >> >>>
> >> >> >>> >> >>> Cheers,
> >> >> >>> >> >>> Daniel
> >> >> >>> >> >>>
> >> >> >>> >> >>> On Tue, Aug 16, 2011 at 1:48 PM, Julien Finet
> >> >> >>> >> >>> <julien.finet at kitware.com>
> >> >> >>> >> >>> wrote:
> >> >> >>> >> >>> > Either that or we make a Q_PROPERTY named "values":
> >> >> >>> >> >>> > Q_PROPERTY( QVector<double> values READ values WRITE
> >> >> >>> >> >>> > setValues)
> >> >> >>> >> >>> > There is already:
> >> >> >>> >> >>> > ctkMatrixWidget::setVector(QVector<double>),
> >> >> >>> >> >>> > maybe
> >> >> >>> >> >>> > it
> >> >> >>> >> >>> > could be renamed into setValues and values() should then
> >> >> >>> >> >>> > also
> >> >> >>> >> >>> > be
> >> >> >>> >> >>> > written.
> >> >> >>> >> >>> > Julien.
> >> >> >>> >> >>> >
> >> >> >>> >> >>> > On Tue, Aug 16, 2011 at 12:37 PM, Daniel Haehn
> >> >> >>> >> >>> > <haehn at bwh.harvard.edu>
> >> >> >>> >> >>> > wrote:
> >> >> >>> >> >>> >>
> >> >> >>> >> >>> >> Hi guys,
> >> >> >>> >> >>> >>
> >> >> >>> >> >>> >> it seems that it is not possible to set a value of a
> >> >> >>> >> >>> >> ctkMatrixWidget
> >> >> >>> >> >>> >> from Python?
> >> >> >>> >> >>> >>
> >> >> >>> >> >>> >> Shall we just enable Q_INVOKABLE on the
> >> >> >>> >> >>> >> ctkMatrixWidget::setValue
> >> >> >>> >> >>> >> method?
> >> >> >>> >> >>> >>
> >> >> >>> >> >>> >> Thanks,
> >> >> >>> >> >>> >> Daniel
> >> >> >>> >> >>> >> _______________________________________________
> >> >> >>> >> >>> >> Ctk-developers mailing list
> >> >> >>> >> >>> >> Ctk-developers at commontk.org
> >> >> >>> >> >>> >>
> >> >> >>> >> >>> >>
> >> >> >>> >> >>> >>
> >> >> >>> >> >>> >>
> http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers
> >> >> >>> >> >>> >
> >> >> >>> >> >>> >
> >> >> >>> >> >>
> >> >> >>> >> >>
> >> >> >>> >> >> _______________________________________________
> >> >> >>> >> >> Ctk-developers mailing list
> >> >> >>> >> >> Ctk-developers at commontk.org
> >> >> >>> >> >>
> >> >> >>> >> >>
> >> >> >>> >> >>
> http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers
> >> >> >>> >> >>
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >> > --
> >> >> >>> >> > +1 919 869 8849
> >> >> >>> >> >
> >> >> >>> >> >
> >> >> >>> >
> >> >> >>> >
> >> >> >>
> >> >> >>
> >> >> >
> >> >
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/ctk-developers/attachments/20110819/b3f5030a/attachment.html>


More information about the Ctk-developers mailing list