Dear Experts,
I’m attaching a simple PyROOT program using “TGMainFrame”.
Unfortunately it crashes at the instruction:
gClient.GetRoot()
and I’m not able to figure out why.
I can reproduce the issue: I’ll look into it and come back to you with some more details.
For the time being, you can continue prototyping replacing the expression:
Hi, it’s me again.
Now the program (here in attachment) is working but somehow it’s not doing what I was hoping.
I thought I could have an “alive” window while doing other things.
For example in the program I instantiate the window and then I start an infinite loop that prints number on the screen.
I was hoping that while it was printing the numbers I could access the window (at the same time), but actually It’s not doing that. While it prints the numbers I can not access the window.
Do you know whether there is an error in my program or the “ROOT Window Manager” is not supposed to work that way I described?
Hi again
I think I understood your example, though I’m not sure how to implement it in my case.
I’ve tried to “thread” TGMainFrame.init but apparently it’s not working.
(I’m attaching the usual example)
Can you please give me an hint on how to implement it in my case ?
Many thanks,
Traceback (most recent call last):
File “TestPyROOT.py”, line 191, in
sys.exit(main())
File “TestPyROOT.py”, line 158, in main
myThread = TThread(“myThread”,filler_function)
TypeError: none of the 5 overloaded methods succeeded. Full details:
TThread::TThread(long id = 0) =>
takes at most 1 arguments (2 given)
TThread::TThread(void*()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 1
TThread::TThread(void()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 1
TThread::TThread(const char* thname, void*()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 2
TThread::TThread(const char* thname, void()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 2
I think you should reconsider the ingredients of your meal E.g. I don’t understand why you want to use TThread here instead of a Python equivalent (which must exist, right?)
Alternatively, if you want to use TThread it might be better to use a C++ function for it to run.
We have some interfaces where we can accept python functions (e.g. fitting), but in general passing python functions to a C++ function that expects a function pointer is courageous.
Hi Axel,
thanks for the reply.
I’m not an expert in programming. I just wanted to develop my program in python and I naively wanted to use TThread within my python program.
I’m not sure I understand how can I use C++ with python.
By the way, is there a way to overcome the problem within Python ?
I don’t know what to say - you are adding lots of complexity to your problem (combining python and C++; and much worse: with threading!) and then asking for a simple solution…
If you indeed want to use the GUI I can warmly recommend you to stay on the C++ side.