TApplication in PyRoot

Dear all,

I’m trying to convert a c++ -root code to pyroot and I get an error at the TApplication section.
The code in c++ is below:

int main(int argc, char **argv)
{
TApplication app(“app”,&argc,argv);

Function(1);

//return 0;
app.Run();
}
How can i write this in python? I thought :

def main():
app = ROOT.TApplication(“app”, 0, 0)
Function(1)
app.Run()

but i get a TypeError:could not convert argument 2!

Thanx

I guess @etejedor can help you.

Hello,

Try with:

 app = ROOT.TApplication("app", ROOT.nullptr, ROOT.nullptr)

Thank you very much! It runs, although it shows this :Error in TApplication::TApplication: only one instance of TApplication allowed

FYI, TApplication is only required when building a standalone application, not when running scripts

yes thank you very much! i am new to this…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.