[Bf-python] Re: Crazy tooltip bug
nicolas bonnand
nicolas.bonnand at wanadoo.fr
Fri Mar 26 01:27:17 CET 2004
Hi Manuel,
I've tried your script, the problem also happens under linux.
I'm not sure, but I would say there's a problem with
the memory management of the tooltip variable
in the draw function.
It behaves as if the malloc of the tooltip
variable was cleared when leaving the draw
function.
(normally it should not happen, even if the tooltip
variable is local to the draw function, because the variable
goes on being used.... But...Maybe something is
wrong with the reference count of the tooltip var ?
Py_INCREF ???? , ...)
An ugly workaround is to give Number() a tooltip variable that is not
local
of the draw function
Look below the modified code
Nicolas
PS: by the way, in the documentation the Number method is supposed to have
11 arguments
Number(name, event, x, y, width, height, initial, min, max, realtime=1,
tooltip=None)
but it doesn't seem to be possible to play with the realtime argument
PS2: have you tried to globally initialize the buttons with
Draw.create() to see if it changes
this behavior ?
import Blender
from Blender.Draw import *
from Blender.BGL import *
listOfNames = ["aa-tooltip1","bb-tooltip2","cc-tooltip3","dd-tooltip4"]
#modif
tooltip=['tooltip1','tooltip2','tooltip3','tooltip4']
def draw():
glClearColor(0.0, 0.0, 0.0, 0.0)
glClear(GL_COLOR_BUFFER_BIT)
i = 0; height = 200
for Name in listOfNames:
buttonName = Name.split(".")[0]
buttonLabel = buttonName.split("-")[0]
Number(buttonLabel, \
1, \ # <- you certainly mean i and not 1
100, \
height, \
100, \
20, \
0.5,\
-1,1,tooltip[i]) # modif
i += 1; height -= 20
print "LABEL AND TOOLTIP: ", buttonLabel, buttonTtip
def bevent(evt):
if (evt):Exit(); return
def event(evt, val):
if (evt== ESCKEY and not val): Exit(); return
else: return
Register(draw, event, bevent)
Register(draw, event, bevent)
More information about the Bf-python
mailing list