NewThreadDialog
Base classes
| Name |
Children |
Inherits |
ModalScreen textual.screen A screen with bindings that take precedence over the App's key bindings. |
|
|
â‹” Inheritance diagram
graph TD
254220584["app.NewThreadDialog"]
1923423225["screen.ModalScreen"]
642899982["screen.Screen"]
3481597255["typing.Generic"]
2751680898["builtins.object"]
4188532303["widget.Widget"]
3946681048["dom.DOMNode"]
53685856["message_pump.MessagePump"]
1923423225 --> 254220584
642899982 --> 1923423225
3481597255 --> 642899982
2751680898 --> 3481597255
4188532303 --> 642899982
3946681048 --> 4188532303
53685856 --> 3946681048
2751680898 --> 53685856
🛈 DocStrings
Bases: ModalScreen[tuple[str, str] | None]
Modal dialog to create a new thread in a chosen project.
Source code in src/acptui/t3/app.py
| class NewThreadDialog(ModalScreen[tuple[str, str] | None]):
"""Modal dialog to create a new thread in a chosen project."""
DEFAULT_CSS = """
NewThreadDialog {
align: center middle;
}
#new-thread-box {
width: 60;
height: auto;
padding: 1 2;
border: round $primary;
background: $surface;
}
#new-thread-box Label {
margin-top: 1;
color: $text-muted;
}
#new-thread-actions {
height: auto;
margin-top: 1;
align: right middle;
}
#new-thread-actions Button {
margin-left: 1;
}
"""
BINDINGS: ClassVar[list[Binding | tuple[str, str] | tuple[str, str, str]]] = [
Binding("escape", "cancel", "Cancel"),
]
def __init__(self, projects: Sequence[ProjectShell]) -> None:
super().__init__()
self._projects = list(projects)
def compose(self) -> ComposeResult:
"""Build project selector and thread title input."""
options = [(p.title, p.id) for p in self._projects]
with Vertical(id="new-thread-box"):
yield Static("New thread", classes="bold")
yield Label("Project")
yield Select(
options, value=options[0][1] if options else Select.BLANK, id="proj-select"
)
yield Label("Title")
yield Input(placeholder="What are we working on?", id="title-input")
with Horizontal(id="new-thread-actions"):
yield Button("Cancel", id="cancel-btn")
yield Button("Create", variant="primary", id="create-btn")
def on_mount(self) -> None:
"""Focus the title input on open."""
self.query_one("#title-input", Input).focus()
def action_cancel(self) -> None:
"""Dismiss without creating a thread."""
self.dismiss(None)
def _submit(self) -> None:
proj = self.query_one("#proj-select", Select).value
title = self.query_one("#title-input", Input).value.strip()
if not isinstance(proj, str) or not title:
return
self.dismiss((proj, title))
def on_input_submitted(self, event: Input.Submitted) -> None:
"""Create on Enter in the title field."""
if event.input.id == "title-input":
self._submit()
def on_button_pressed(self, event: Button.Pressed) -> None:
"""Handle Cancel / Create buttons."""
if event.button.id == "cancel-btn":
self.dismiss(None)
elif event.button.id == "create-btn":
self._submit()
|
action_cancel
Dismiss without creating a thread.
Source code in src/acptui/t3/app.py
| def action_cancel(self) -> None:
"""Dismiss without creating a thread."""
self.dismiss(None)
|
compose
compose() -> ComposeResult
Build project selector and thread title input.
Source code in src/acptui/t3/app.py
| def compose(self) -> ComposeResult:
"""Build project selector and thread title input."""
options = [(p.title, p.id) for p in self._projects]
with Vertical(id="new-thread-box"):
yield Static("New thread", classes="bold")
yield Label("Project")
yield Select(
options, value=options[0][1] if options else Select.BLANK, id="proj-select"
)
yield Label("Title")
yield Input(placeholder="What are we working on?", id="title-input")
with Horizontal(id="new-thread-actions"):
yield Button("Cancel", id="cancel-btn")
yield Button("Create", variant="primary", id="create-btn")
|
on_button_pressed(event: Pressed) -> None
Handle Cancel / Create buttons.
Source code in src/acptui/t3/app.py
| def on_button_pressed(self, event: Button.Pressed) -> None:
"""Handle Cancel / Create buttons."""
if event.button.id == "cancel-btn":
self.dismiss(None)
elif event.button.id == "create-btn":
self._submit()
|
on_input_submitted(event: Submitted) -> None
Create on Enter in the title field.
Source code in src/acptui/t3/app.py
| def on_input_submitted(self, event: Input.Submitted) -> None:
"""Create on Enter in the title field."""
if event.input.id == "title-input":
self._submit()
|
on_mount
Focus the title input on open.
Source code in src/acptui/t3/app.py
| def on_mount(self) -> None:
"""Focus the title input on open."""
self.query_one("#title-input", Input).focus()
|
:fa-brands-github: Show source on GitHub