PyROOT hangs on Canvas Update()

Hi, I’ve encountered the following problem:
I define a custom function in Python which I want to draw or use in a fit. This works nicely, but as soon as I call the canvas’s Update() method, the process hangs and the window does not update at all.
If I just leave that call out and manually update by clicking into the window, everything works.
I think I’ve isolated the problem to the following code:

[code]import ROOT

def func(x): # does not seem to matter whether there are parameters or the function actually does something
pass
f = ROOT.TF1(‘func’, func, 0, 1)
c = ROOT.TCanvas(‘c’)
f.Draw()
c.Update() #<-- seems to break things[/code]

Software I am using:
ROOT 5.28/00 (trunk@37585, Dec 14 2010, 15:20:27 on win32)
D:\Python26\pythonw.exe 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
on a Windows 7 Professional, 64bit.

Hi,

I do not currently have access to a Windows box, and will try when I have a chance. There’s a long history on lockups of the graphics threads on Windows.

Cheers,
Wim

Hi Wim,
thanks for your reply!
Is there anything I can do to assist in shedding light on this issue?

Hi,

I cannot reproduce the problem. There is no problem executing the code below:

[code]c:\Users\bellenot\rootdev>python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type “help”, “copyright”, “credits” or “license” for more information.

import ROOT
f = ROOT.TF1( ‘func’, ‘abs(sin(x)/x)’, 0, 10 )
c = ROOT.TCanvas(‘c’)
f.Draw()
c.Update()
[/code]
And running the same in a python script works as well…

Cheers, Bertrand.

[quote=“bellenot”]Hi,

I cannot reproduce the problem. There is no problem executing the code below
And running the same in a python script works as well…

Cheers, Bertrand.[/quote]

Hi Bertrand,

have you tried executing the exact same snippet I posted above?
I also do not have any problems executing your snippet in a shell or script.
The freeze seems to be related to the custom python function and does not occur when constructing a TF1 via formula string. I can also reproduce the error on another Win7 box running the same software configuration with the code I posted.
One thing I did not try were all the older 2.6.x versions of python, only 2.6.5 and 2.6.6, I’ll do that tomorrow.

Cheers,
Markus

Hi Markus,

OK, I see, your piece of code code hangs (no need to try with other versions of Python). I’ll try to see what’s happening, but as it seems to be a very Python related problem, I hope Wim will manage to debug it, or at least to give some advice, since I’m not a Python expert (not even a Python user…)

Cheers, Bertrand.