Search code examples
pythoncheckboxwxpython

Need To Select Only One Checkbox In Group


I am working on a screen written in wxPython, and Python, that has five groups of CheckBoxes. Three of the groups can have between none and all the CheckBoxes selected. However with two of the groups only none or one can be selected. RadioButtons have been considered and disregarded as you cannot select none and their appearance is different making the look and feel of the page inconsistent. Obviously I could write numerous OnCheckBox events that would all be very similar. Is there an easier and more elegant way of achieving this?


Solution

  • Have you considered cycling through them on EVT_CHECKBOX.
    Each box can be tested with IsChecked(), if the test is True then you can use SetValue(False) on the others or whatever suits your requirements.
    Also, there is nothing to stop you creating a radiobutton with the value None.