The object constructors use the current style. Creating a new style does not change the existing object attributes.
see also gROOT->ForceStyle and TObject::UseCurrentSyle, eg myHist.UseCurrentStyle()
the problem is not this. The python code and C++ code are equivalent, but the C++ works, python not. There is no difference if first I set the style first and then I create the histogram:
set_style()
h = ROOT.TH1F("h","h",100,0,100)
h.Fill(20)
h.Draw()
the difference between the C++ version and the python one is the un-matched new in C++. In order to achieve the same with python, one has to do “ROOT.SetOwnership( my_style, False )”.
I looked at the ownership rules specific to the TStyle class, and it appears that it can’t in any way be managed externally (it’s ctor and dtor always talk to gROOT’s ListOfStyles). I’ve therefore changed the code in Pythonize.cxx to make TStyle instances always be not-owned by python. New code is in trunk.