trading_agent.terminal.widgets.confirm_dialog
¶
A dialog that asks for a reason, and sometimes a typed word, before a serious action such as flattening a desk or firing the kill switch.
It copies the web page's ConfirmDialog.tsx: the action cannot be confirmed until a reason is written, and, when a word is required, until that exact word is typed. It returns the reason, or None when cancelled.
Typical usage example:
app.push_screen(ConfirmDialog('Fire the kill switch', explanation, 'Fire', word='FLATTEN'), on_reason)
ConfirmDialog
¶
Bases: ModalScreen[str | None]
The confirmation dialog.
Creates the dialog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
What is about to happen. |
required |
explanation
|
str
|
What it does, in a sentence or two. |
required |
action_label
|
str
|
The word for confirming, such as "Flatten". |
required |
word
|
str | None
|
A word the user must type to confirm, or None. |
None
|
Source code in src/trading_agent/terminal/widgets/confirm_dialog.py
compose
¶
Builds the dialog.
Yields:
| Type | Description |
|---|---|
Widget
|
The title, the explanation, the reason box, the word box when needed, the error line and the hint. |
Source code in src/trading_agent/terminal/widgets/confirm_dialog.py
on_mount
¶
on_input_submitted
¶
Confirms when the reason, and the word if needed, are given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Submitted
|
The submission. |
required |