Change which button has the "check" in DirectRadioButton by code after it is created?

https://docs.panda3d.org/1.10/python/programming/directgui/directradiobutton

I don’t think the info is in the manual, or maybe I’m misunderstanding some part.

I think that the relevant method is “check”. That is, you would activate a radio-button like so:

self.myRadioButton.check()

(See the API for a fuller listing of available methods.)

Thanks. I tried that already, but it didn’t work. But this is most likely due to a bug in my code as it works fine with the sample code from the manual page.

PS. The check() and uncheck() methods could be added to the manual page, or at least should have docstrings.

I do agree that the API could use more descriptions of the various methods catalogued there.

While I’m wary of ending up adding near-every method to the manual, I could see those two being added–they are quite useful, I think.

1 Like

To give my specific use case, I wanted a way to reset a bunch of radiobuttons to their default values with a click of a button and easiest way seemed to be to do uncheck() on all buttons except one and do check() on that one.

As a minor point, if the buttons are set to be connected to each other (via the “setOthers” method), I believe that you needn’t uncheck any of the buttons: you should be able to just call “check” on the one button that you want to have checked, as the others should be automatically unchecked as a result.

If you see anything that can be improved in the manual, please file an issue here:

1 Like