Clear RadioButton selection in a RadioSet #6197
                  
                    
                      Daniel-Chin
                    
                  
                
                  started this conversation in
                Ideas
              
            Replies: 1 comment 5 replies
-
| The  textual/src/textual/widgets/_radio_set.py Lines 241 to 242 in 3427dba I don't quite understand why you'd want to clear a  | 
Beta Was this translation helpful? Give feedback.
                  
                    5 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
When the app initializes, it is possible that no RadioButton is selected in a set of RadioButtons. In this state, each
radioButton.value == Falseand theradioSet.pressed_index == -1. This is the documented, intended behavior.The possibility of an unset RadioSet opens up vast applications. It's a nullable enum. In my application, I want a yes/no radioSet to be unset as the default and require user action without suggesting either.
However, currently, there seems no way to programmatically unset / clear all radioButtons in a radioSet.
Curiously, I played with Textual source code and couldn't figure out an implementation. The states,
RadioSet._pressed_buttonandRadioButton.value, seem to work beyond my comprehension.Beta Was this translation helpful? Give feedback.
All reactions