You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Qt, QComboBox can be switched into the editable state. There, speaking the language of textual, SelectCurrent shows an Input instead of a Static. When the Input is submitted, the Changed message gets sent.
So, that's what I'm asking for. Please make a switch to make a Select editable. If it's too hard to implement, make a separate class. But for some cases, the latter approach will lead to a code doubling for the end user.
That's what I've got so far. It's next to a carbon copy of what you've made.
classEditaleSelectCurrent(SelectCurrent):
"""Displays the currently selected option."""value: reactive[str] =reactive("")
placeholder: reactive[str] =reactive("")
def__init__(self, placeholder: str) ->None:
"""Initialize the EditaleSelectCurrent. Args: placeholder: A string to display when there is nothing selected. """super().__init__()
self.placeholder=placeholderdefupdate(self, label: RenderableType|None) ->None:
"""Update the content in the widget. Args: label: A renderable to display, or `None` for the placeholder. """self.has_value=labelisnotNoneself.value=labelor""defcompose(self) ->ComposeResult:
"""Compose label and down arrow."""yieldInput(placeholder=self.placeholder).data_bind(
SelectCurrent.value, SelectCurrent.placeholder
)
yieldStatic("▼", classes="arrow down-arrow")
yieldStatic("▲", classes="arrow up-arrow")
def_on_input_changed(self, message: Input.Changed) ->None:
message.stop()
withself.query_one(Input).prevent(Input.Changed):
self.value=message.value
Then, the Input.value should be treated as valid by Select unless it's blank and therefore is disallowed.
And Select should catch Input.Submitted messages to convert them into Select.Changed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
In Qt,
QComboBoxcan be switched into the editable state. There, speaking the language oftextual,SelectCurrentshows anInputinstead of aStatic. When theInputis submitted, theChangedmessage gets sent.So, that's what I'm asking for. Please make a switch to make a
Selecteditable. If it's too hard to implement, make a separate class. But for some cases, the latter approach will lead to a code doubling for the end user.That's what I've got so far. It's next to a carbon copy of what you've made.
Then, the
Input.valueshould be treated as valid bySelectunless it's blank and therefore is disallowed.And
Selectshould catchInput.Submittedmessages to convert them intoSelect.Changed.Beta Was this translation helpful? Give feedback.
All reactions