[Bf-python] event ID questions - partly solved
Thomas Bleicher
tbleicher at arcor.de
Wed Aug 3 22:36:26 CEST 2005
After rereading the sources again I found something and can
answer this myself:
On Wed, Aug 03, 2005 at 15:31:23 +0200, Thomas Bleicher wrote:
> Now the questions:
>
>
> 1) I have up to 80 buttons to create at one time. This is no problem
> but I don't know where to find a large enough range of IDs for
> these buttons that's not already used for other signals (ie.
> event 8 was generated when a menu button was left _without_ changing
> its value).
I have to appologize for this report. I fear I've tested my script
accidentally with version 2.35. I tried it again right now and could
not reproduce this behaviour with 2.37.
I think the solution is this (I don't have the 2.35 source to
compare with so I can't say when it was introduced):
In source/blender/python/api2_2x/Draw.c the following constants
are defined for this purpose:
#define EXPP_BUTTON_EVENTS_OFFSET 1001
#define EXPP_BUTTON_EVENTS_MIN 0
#define EXPP_BUTTON_EVENTS_MAX 15382 /* 16384 - 1 - OFFSET */
If someone gets it wrong, an error message is generated as well:
"button event argument must be in the range [0, 16382]"
This message is partly wrong, though, as the check_button_event
checks against EXPP_BUTTON_EVENTS_MAX, which is 15382. In Python
I'd use
"button event ... in the range [0, %d]" % EXPP_BUTTON_EVENTS_MAX
but I don't know if this is that easy in C.
> If there is no continuous range where can I find events which are
> already assigned to something? Other toolkits offer a way to
> generate/access the next usable ID; for example wxWindows:
>
> id = newId() # iirc; haven't used it for some time
>
> Would this be possible/a good idea for BPY?
Still might be a good idea.
Thomas
More information about the Bf-python
mailing list