Re: Can TPad::AddExec call a method in PyROOT?

From: <wlavrijsen_at_lbl.gov>
Date: Mon, 12 Dec 2011 16:01:09 -0800


Akira,

> I wrote a Python class which has a TCanvas as a member, and a method which
> is intended to do some calculations according to the mouse cursor position,
> as in $ROOTSYS/tutorials/pyroot/DynamicSlice.py

the tutorial makes use of finding the callable from the global space, and then calling it. Python methods can be bound, and then passed around as objects.

> --------------
> class MyClass(object):
> def __init__(self):
> self.can = ROOT.TCanvas()
> self.can.AddExec('dynamic', ???) # how to call self.doSomething ?

Something like:

     import __main__
     __main__.doSomething = self.doSomething
     self.can.AddExec( 'dynamic', 'TPython::Exec( "doSomething()" )' )

Not particularly pretty, but should work.

Best regards,

            Wim

-- 
WLavrijsen_at_lbl.gov    --    +1 (510) 486 6411    --    www.lavrijsen.net
Received on Tue Dec 13 2011 - 01:01:22 CET

This archive was generated by hypermail 2.2.0 : Tue Dec 13 2011 - 11:50:01 CET