Skip to content

Add clear() method to RadioSet#6232

Closed
nikhil2004-blip wants to merge 1 commit intoTextualize:mainfrom
nikhil2004-blip:feat/radioset-clear-6198
Closed

Add clear() method to RadioSet#6232
nikhil2004-blip wants to merge 1 commit intoTextualize:mainfrom
nikhil2004-blip:feat/radioset-clear-6198

Conversation

@nikhil2004-blip
Copy link
Copy Markdown

Description

Adds a clear() method to RadioSet that deselects all radio buttons, returning the set to its initial unset state.

Changes

  • Implements RadioSet.clear() to deselect all buttons
  • Returns RadioSet to initial unset state
  • Updated RadioSet._on_radio_set_changed() to handle cleared state (index=-1)
  • Updated RadioSet.Changed.__init__() to accept pressed: RadioButton | None
  • Useful for surveys/questionnaires where no response is valid
  • Fixes Adding an option to clear the RadioSet #6198

Motivation

As discussed in #6197, this enables use cases where an unset RadioSet is needed, such as survey interfaces where "no response" is a valid state, without requiring a "Skip" button workaround.

Usage Example

from textual.widgets import RadioSet

radio_set = RadioSet("Yes", "No")
# User selects something...
radio_set.clear()  # Now nothing is selected

Testing

Added comprehensive tests in tests/test_radio_set_clear.py covering:

  • Basic clear functionality
  • Clearing empty RadioSet
  • Multiple clears (idempotent)
  • Selecting after clearing

Please review the following checklist.

  • [✅ ] Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

after review i can update documentation and CHANGELOG.md

- Implements RadioSet.clear() to deselect all buttons
- Returns RadioSet to initial unset state
- Useful for surveys/questionnaires where no response is valid
- Fixes #6198
@nikhil2004-blip
Copy link
Copy Markdown
Author

any update regarding this issue and my fix ??

@TomJGooding
Copy link
Copy Markdown
Contributor

Based on your other PRs, was this just generated using AI?

@nikhil2004-blip
Copy link
Copy Markdown
Author

nikhil2004-blip commented Feb 4, 2026

Based on your other PRs, was this just generated using AI?

I took help but i have checked it is deselecting the radio buttons

@TomJGooding
Copy link
Copy Markdown
Contributor

TomJGooding commented Feb 4, 2026

test_can_select_after_clear makes no sense, so closing as yet more AI slop.

Please stop wasting the time of open source maintainers.

@TomJGooding TomJGooding closed this Feb 4, 2026
@nikhil2004-blip nikhil2004-blip deleted the feat/radioset-clear-6198 branch February 4, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding an option to clear the RadioSet

2 participants