14from ROOT
import pythonization
25ROOT.gInterpreter.Declare(
'''
54@pythonization('MyClass')
55def pythonizor_of_myclass(klass):
56 klass.__str__ =
lambda o :
'This is a MyClass object'
63my_object = ROOT.MyClass()
82ROOT.gInterpreter.Declare(
'''
93@pythonization(['Class1', 'Class2'], ns='NS')
94def pythonize_two_classes(klass):
95 klass.new_attribute = 1
100print(
"Printing new attribute")
102 print(o.new_attribute)
112@pythonization('vector<', ns='std', is_prefix=True)
113def vector_pythonizor(klass):
115 klass.first_elem =
lambda v : v[0]
if v
else None
119v_int = ROOT.std.vector[
'int']([1,2,3])
120v_double = ROOT.std.vector[
'double']([4.,5.,6.])
121print(
"First element of integer vector: {}".
format(v_int.first_elem()))
122print(
"First element of double vector: {}".
format(v_double.first_elem()))
140@pythonization('pair<', ns='std', is_prefix=True)
141def pair_pythonizor(klass, name):
142 print(
'Pythonizing class ' + name)
148p1 = ROOT.std.pair[
'int',
'int'](1,2)
149p2 = ROOT.std.pair[
'int',
'double'](1,2.)
154ROOT.gInterpreter.Declare(
'''
157 class SecondClass {};
162@pythonization('FirstClass')
163@pythonization('SecondClass', ns='NS')
164def pythonizor_for_first_and_second(klass, name):
165 print(
'Executed for class ' + name)
169s = ROOT.NS.SecondClass()
184ROOT.gInterpreter.Declare(
'''
190except AttributeError:
191 print(
"Object has not been pythonized yet!")
195@pythonization('MyClass2')
196def pythonizor_for_myclass2(klass):
197 klass.pythonized =
True
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format