Repository: Textualize/textual

Issue:
Setting `Select.value` in `on_mount` for a `Select` in a container raises an exception
Initially stemming from [a question on Discord](https://discord.com/channels/1026214085173461072/1033754296224841768/1111680440709947533), it seems that it isn't possible to set `Select.value` in `on_mount` if the `Select` is inside a container. That is to say, this code works fine:

```python
from textual.app        import App, ComposeResult
from textual.widgets    import Select

class SelectBugApp( App[ None ] ):

    def on_mount( self ) -> None:
        self.query_one( Select ).value = 1

    def compose( self ) -> ComposeResult:
        yield Select( ( ( str( n ), n ) for n in range( 10 ) ) )

if __name__ == "__main__":
    SelectBugApp().run()
```

but this code:

```python
from textual.app        import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets    import Select

class SelectBugApp( App[ None ] ):

    def on_mount( self ) -> None:
        self.query_one( Select ).value = 1

    def compose( self ) -> ComposeResult:
        yield Horizontal( Select( ( ( str( n ), n ) for n in range( 10 ) ) ) )

if __name__ == "__main__":
    SelectBugApp().run()
```

raises this error:

```
╭───────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────╮
│ /Users/davep/develop/python/textual-sandbox/select_value.py:8 in on_mount                                                                    │
│                                                                                                                                              │
│    5 class SelectBugApp( App[ None ] ):                                                                                                      │
│    6 │                                                                                                                                       │
│    7 │   def on_mount( self ) -> None:                                                                                                       │
│ ❱  8 │   │   self.query_one( Select ).value = 1                                                                                              │
│    9 │                                                                                                                                       │
│   10 │   def compose( self ) -> ComposeResult:                                                                                               │
│   11 │   │   yield Horizontal( Select( ( ( str( n ), n ) for n in range( 10 ) ) ) )                                                          │
│                                                                                                                                              │
│ ╭───────────────────────────── locals ──────────────────────────────╮                                                                        │
│ │ self = SelectBugApp(title='SelectBugApp', classes={'-dark-mode'}) │                                                                        │
│ ╰───────────────────────────────────────────────────────────────────╯                                                                        │
│                                                                                                                                              │
│ /Users/davep/develop/python/textual-sandbox/.venv/lib/python3.10/site-packages/textual/widgets/_select.py:310 in _watch_value                │
│                                                                                                                                              │
│   307 │   │   │   if value is None:                                                                                                          │
│   308 │   │   │   │   self.query_one(SelectCurrent).update(None)                                                                             │
│   309 │   │   │   else:                                                                                                                      │
│ ❱ 310 │   │   │   │   for index, (prompt, _value) in enumerate(self._options):                                                               │
│   311 │   │   │   │   │   if _value == value:                                                                                                │
│   312 │   │   │   │   │   │   select_overlay = self.query_one(SelectOverlay)                                                                 │
│   313 │   │   │   │   │   │   select_overlay.highlighted = index                                                                             │
│                                                                                                                                              │
│ ╭────────────────────────── locals ──────────────────────────╮                                                                               │
│ │ select_current = SelectCurrent(pseudo_classes={'enabled'}) │                                                                               │
│ │           self = Select(pseudo_classes={'enabled'})        │                                                                               │
│ │          value = 1                                         │                                                                               │
│ ╰────────────────────────────────────────────────────────────╯                                                                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'Select' object has no attribute '_options'
```


Discussion:

Resolving patch:
diff --git a/src/textual/widgets/_select.py b/src/textual/widgets/_select.py
--- a/src/textual/widgets/_select.py
+++ b/src/textual/widgets/_select.py
@@ -273,6 +273,7 @@ def __init__(
         self.prompt = prompt
         self._initial_options = list(options)
         self._value: SelectType | None = value
+        self._options = options
 
     def set_options(self, options: Iterable[tuple[RenderableType, SelectType]]) -> None:
         """Set the options for the Select.


Test patch: