DirectRadioButton: "models/gui/radio_button_gui"

I’m not sure that this is the best way to report this, but I wasn’t sure of where else to do so. My apologies if this is the wrong place. ^^;

I recently stumbled on an issue in using DirectRadioButton: When attempting to run an installed version of a prototype on another computer, the program crashed, the error log reporting that it had failed to load “models/gui/radio_button_gui”.

Having faced similar issues previously with DirectDialog, I recognised the problem as being simply that I hadn’t included the default models. Not wanting to do so, I had a little bit of fun making a custom radio button. After a little bit of effort, I managed to customise my radio buttons–not perfectly, but acceptably for the prototype.

I built a new version, uploaded it, downloaded it to the test computer, ran it–and it crashed again. With the same error in the log.

Looking at the code for DirectRadioButton, the problem appears to be that, when specifying its default keyword arguments, it actually attempts to load the above-quoted model, regardless of whether or not the appropriate keyword has been specified; as a result, it appears that DirectRadioButton will only work when there is something valid at “models/gui/radio_button_gui”.

The relevant line of code (line 46 in my version), taken from the definition of “optiondefs”:

('boxImage', loader.loadModel('models/gui/radio_button_gui'), None),

This was found in a version of Panda custom-built from the CVS, albeit last updated… I’m not sure–perhaps a few weeks ago.

I can get around this for now, but this seems a little awkward if one intends to customise the button.

Could the default not be specified as a string, rather than the actual loaded model?

I’ve hacked a workaround into my copy of DirectRadioButton.py:
Line 46, instead of loading the model regardless of parameters, it now defaults to “None”:

('boxImage', None, None),

Line 55, inserted after “DirectButton.init(…” and before “self.indicator = …”, the model is loaded if “boxImage” is None:

if self['boxImage'] is None:
		self['boxImage'] = loader.loadModel('models/gui/radio_button_gui')

I haven’t tested this properly, but it seems to work thus far, allowing both a default model without requiring the RadioButton model in re-skinned RadioButtons.