trading_agent.terminal.widgets.question_card
¶
The card for a desk's questions (ask_user), as the web page's QuestionCard.tsx shows them.
One to four questions, each with two to four options and an "Other" answer. With several questions there is one tab per question and a final tab to review and submit. A single question with a single choice is sent as soon as an option is picked.
Keys: Up and Down move, Enter or a number picks (a multiple-choice question ticks and unticks), the number after the last option goes to the Other box, Tab and Shift+Tab move between questions, Ctrl+S submits, Ctrl+X dismisses without answering.
Typical usage example:
card = QuestionCard(request, gateway)
QuestionCard
¶
Bases: Vertical
A card for answering the desk's questions.
Creates the card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
dict[str, Any]
|
The pending question request. |
required |
gateway
|
GatewayClient
|
The gateway, to send the answers. |
required |
Source code in src/trading_agent/terminal/widgets/question_card.py
Done
¶
Bases: Message
The request was answered or dismissed.
compose
¶
Builds the card.
Yields:
| Type | Description |
|---|---|
Widget
|
The heading, tabs, question, options, Other box, preview, review, error and hint. |
Source code in src/trading_agent/terminal/widgets/question_card.py
on_mount
¶
focus_card
¶
Puts the focus on the options, so the card's keys work.
on_key
¶
Picks an option with its number key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Key
|
The key press. |
required |
Source code in src/trading_agent/terminal/widgets/question_card.py
on_option_list_option_highlighted
¶
Shows the highlighted option's preview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
OptionHighlighted
|
The highlight. |
required |
Source code in src/trading_agent/terminal/widgets/question_card.py
on_option_list_option_selected
¶
Picks the selected option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
OptionSelected
|
The selection. |
required |
Source code in src/trading_agent/terminal/widgets/question_card.py
on_input_changed
¶
Keeps the Other answer; for a single choice it replaces the picked option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Changed
|
The change. |
required |
Source code in src/trading_agent/terminal/widgets/question_card.py
on_input_submitted
¶
Moves on, or submits, after an Other answer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Submitted
|
The submission. |
required |
Source code in src/trading_agent/terminal/widgets/question_card.py
action_next_question
¶
Shows the next question, or the review tab after the last.
Source code in src/trading_agent/terminal/widgets/question_card.py
action_previous_question
¶
Shows the previous question.
action_submit
¶
Sends the answers, when every question has one.