[Bf-python] Re: Crazy tooltip bug

Stephen Swaney sswaney at swbell.net
Sat Apr 3 05:11:23 CEST 2004


Willian Padovani Germano wrote:
>
> Yes, since the tooltip is needed after the function returns and is local
> to it, probably it should be copied to a Blender managed piece of
> storage and code should be added to the py destructor to get rid of it
> when the button goes away.  Will you fix it yourself, Steve, like you
> did for a similar problem in Draw.c earlier?

We've had some discussion about this with Ton.  Our conclusion
is that changes need to be made in Blender's uiBut structs.
Doing it in the python code does not work for a couple reasons.

One is that since the GUI buttons can be created inside ( and destroyed
)
inside the draw() callback, they can go out of scope and not be
available when the tooltip event occurs.  The other reason is 
that some of the GUI creation functions in the Draw module
don't return a python object.

The 'most correct' fix is to have the uiBut save off it's own
copy of the tooltip string.  Ton wanted to be involved in
this, but is working on some rendering issues at the moment.

In the meantime, we have a useable workaround:  create the
tooltip strings outside the draw() callback.  This is not
a difficult burden.  This bug only showed up for the original
poster due to some clever programming where he parsed the
tooltip strings out of strings created globally in his script
and made local copies for the draw() callback.

I will make some usage notes in the documentation about this.
When the problem gets fixed, we can yank them back out.  No
code written using the workaround will be broken by the internal
blender fix, so I don't see any user issues with this.

-- 
Stephen Swaney			
sswaney at swbell.net



More information about the Bf-python mailing list