pyROOT 6 and gVirtualX, EEventType, etc


ROOT Version (e.g. 6.12/02): 6.13.02
Platform, compiler (e.g. CentOS 7.3, gcc6.2): Fedora 27
Python 2.7.14


Hello,

I’d like to make my pyROOT app ROOT 6 ready for one day when it will have windows support and will be adopted by more tools. However, there are problems:

  1. ROOT.gVirtualX.GrabKey(self.GetId(), ROOT.gVirtualX.KeysymToKeycode(ROOT.kKey_j), ROOT.kKeyControlMask, True) and similar do not work. I get:
    RuntimeWarning: creating converter for unknown type “TTVirtualX**”
    What should be used instead?

  2. if ROOT.gPad.GetEvent() == ROOT.EEventType.kButton1Down:
    AttributeError: type object ‘int’ has no attribute ‘kButton1Down’
    I’ve tried perhaps 3 different enumerations in pyROOT 6, and all of them resolve to “int”. What should be used instead?

  3. I can’t go further with errors in my app before resolving those, so there may be many more similar errors awaiting. Is there any document about migration from ROOT 5 to ROOT 6?

  4. Calling TGWindow with ROOT.gClient.GetRoot() as an argument crashes the app - visible when one tries to execute gui_ex.py from tutorials. I found on this forum that it can be fixed with providing ROOT.TGClient.Instance().GetRoot() instead. What is the reason for keeping a broken version of gui_ex.py?

Thank you in advance for help!

I think I’ve found solutions to 1 and 2 myself:

  1. Replace ROOT.gVirtualX with ROOT.TVirtualX.Instance(). So, perhaps ROOT.gVirtualX could be initialised to this by default?

  2. I understand that in ROOT 6 enums are directly put into ROOT.*, so I need to check ROOT.kButton1Down instead of ROOT.EEventType.kButton1Down. I guess this is intentionall, but if in addition the old “addressing” could be restored, it would increase the compatibility…

Questions 3 and 4 still hold :slight_smile:

Hi @LeWhoo,

I am afraid there is no specific guide of how to migrate your PyROOT application from ROOT 5 to 6, but we will gladly answer your questions in this forum in case more issues arise.

Regarding the gui_ex.py tutorial, thank you for spotting that, we will fix it.

Enric

Rather than

ROOT.TVirtualX.Instance();

consider

ROOT.gApplication.InitializeGraphics();

Cheers,
Phlippe.

Perhaps noting small tips & tricks like the ones that I just found and puting them on some webpage could be considered?

Hmm, I am not sure how should I use that. ROOT.TVirtualX.Instance() returns TVirtualX, on which I can call GrabKey() (that’s what I use it for). While ROOT.gApplication.InitializeGraphics() returns void…

Thanks for the suggestion, we are actually creating a Howto integrated in the new forum so that we can more easily redirect users to previously answered questions that are common.

If it will be well indexed by Google, then great!

You (of course :slight_smile: ) needs to return to using ROOT.gVirtualX

Cheers,
Philippe.

So the fact that ROOT.gVirtualX gives:
RuntimeWarning: creating converter for unknown type “TTVirtualX**”
is a bug or something expected?

Yes, this seems like a bug PyROOT. @etejedor Can you take a look?

A JIRA ticket has been opened to track the issue:

https://sft.its.cern.ch/jira/browse/ROOT-9364

Issue understood and addressed by:

The PR has been merged, you should no longer see the issue if you work with the current master.

Great!

So, just to confirm another thing. Is ROOT.kButton1Down in ROOT 6 instead of ROOT.EEventType.kButton1Down in ROOT 5 a planned change or a bug?

From what I see in ROOT 6, in the C++ ROOT prompt, you can access directly kButton1Down, so Python is just replicating that behaviour.

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