DirectCheckButton images

Greetings all!

I’m trying to wrap my brain around the “DirectCheckButton” class. It seems fairly self-explanatory, but I’m having some trouble with the ‘boxImage’ property. I know that the DirectButton itself needs four states for images (idle, rollover, clicking, and disabled). However, the boxImage appears to need three images for states, where I expect it to only need two: unchecked and checked.

Does anyone know why the third image is needed? Attempting to build a DirectCheckButton with this argument bombs:


boxImage=("checkEmpty.jpg","check.jpg")

… but building with this works:


boxImage=("checkEmpty.jpg","check.jpg",None)

Thank you for the help!

-Mark

This is just an accident of the different (ambiguous) value types that may be supplied for an image parameter. By convention, an image parameter may be any of:

a) A Texture object.
b) A texture filename.
c) A 2-tuple of the form (‘model_filename’, ‘node_name’), where model_filename is the path to a bam or egg file, and node_name is some search string within that path, e.g. ‘**/mynode’.
d) A tuple of any of the above, one for each state.

Unfortunately, when you supply a 2-tuple of strings, which is intended to be case (d) wrapped around case (b), it mistakes this for case © instead. Then it fails, because the first filename is a texture filename, not a model filename.

A workaround is to make it a 3-tuple, as you have done; or to preload the Texture objects via loader.loadTexture() and pass a 2-tuple of those instead.

David

Excellent; thank you for the assistance!

I’ve made a minor edit to the manual to reflect this information, since it wasn’t really clear from the original manual page that you could set different properties for the two states of the check box (it makes ‘common sense,’ but the check box inherited from DirectButton and so it seemed more likely that it would allow the four button states, not ‘unchecked, checked’ states). Feel free to add any more information to the entry that I left out!

-Mark