Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Textualize/textual into themes
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Oct 14, 2024
2 parents 2da1f4c + 4182ad4 commit c0e3d69
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 31 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

# Python 3.9 is on macos-13 but not macos-latest (macos-14-arm64)
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
exclude:
- { python-version: "3.8", os: "macos-latest" }
- { python-version: "3.9", os: "macos-latest" }
- { python-version: "3.11", os: "macos-latest" }
include:
- { python-version: "3.8", os: "macos-13" }
- { python-version: "3.9", os: "macos-13" }
- { python-version: "3.11", os: "macos-13" }
defaults:
run:
shell: bash
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Fixed

- Fixed `RadioSet` not being scrollable https://github.com/Textualize/textual/issues/5100

## [0.83.0] - 2024-10-10

### Added
Expand Down
25 changes: 15 additions & 10 deletions src/textual/widgets/_radio_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

from textual import _widget_navigation
from textual.binding import Binding, BindingType
from textual.containers import Container
from textual.containers import VerticalScroll
from textual.events import Click, Mount
from textual.message import Message
from textual.reactive import var
from textual.widgets._radio_button import RadioButton


class RadioSet(Container, can_focus=True, can_focus_children=False):
class RadioSet(VerticalScroll, can_focus=True, can_focus_children=False):
"""Widget for grouping a collection of radio buttons into a set.
When a collection of [`RadioButton`][textual.widgets.RadioButton]s are
Expand All @@ -33,17 +33,17 @@ class RadioSet(Container, can_focus=True, can_focus_children=False):
height: auto;
width: auto;
& > RadioButton {
background: transparent;
border: none;
padding: 0 1;
}
& > RadioButton.-selected {
color: $text;
background: $highlight-cursor-blurred;
}
& > * {
background: transparent;
border: none;
padding: 0;
}
& .toggle--button {
color: $surface;
background: $foreground 15%;
Expand Down Expand Up @@ -84,8 +84,6 @@ class RadioSet(Container, can_focus=True, can_focus_children=False):
}
}
}
"""

BINDINGS: ClassVar[list[BindingType]] = [
Expand Down Expand Up @@ -215,6 +213,7 @@ def watch__selected(self) -> None:
self.query(RadioButton).remove_class("-selected")
if self._selected is not None:
self._nodes[self._selected].add_class("-selected")
self._scroll_to_selected()

def _on_radio_button_changed(self, event: RadioButton.Changed) -> None:
"""Respond to the value of a button in the set being changed.
Expand Down Expand Up @@ -303,3 +302,9 @@ def action_toggle_button(self) -> None:
button = self._nodes[self._selected]
assert isinstance(button, RadioButton)
button.toggle()

def _scroll_to_selected(self) -> None:
"""Ensure that the selected button is in view."""
if self._selected is not None:
button = self._nodes[self._selected]
self.call_after_refresh(self.scroll_to_widget, button, animate=False)
Loading

0 comments on commit c0e3d69

Please sign in to comment.