Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnDecoratorError with Select handler having CSS selector #2648

Closed
davetapley opened this issue May 24, 2023 · 3 comments · Fixed by #2602
Closed

OnDecoratorError with Select handler having CSS selector #2648

davetapley opened this issue May 24, 2023 · 3 comments · Fixed by #2602

Comments

@davetapley
Copy link
Contributor

Building upon this, but adding #line selector:

from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Header, Select

LINES = """I must not fear.
Fear is the mind-killer.
Fear is the little-death that brings total obliteration.
I will face my fear.
I will permit it to pass over me and through me.""".splitlines()


class SelectApp(App):
    def compose(self) -> ComposeResult:
        yield Header()
        yield Select(((line, line) for line in LINES), id="line")

    @on(Select.Changed, "#line")
    def select_changed(self, event: Select.Changed) -> None:
        self.title = str(event.value)


if __name__ == "__main__":
    app = SelectApp()
    app.run()

Causes:

Traceback (most recent call last):
  File "/home/dave/ng/textual-select-on.py", line 12, in <module>
    class SelectApp(App):
  File "/home/dave/ng/textual-select-on.py", line 17, in SelectApp
    @on(Select.Changed, "#line")
  File "/home/dave/.pyenv/versions/ng/lib/python3.10/site-packages/textual/_on.py", line 69, in on
    raise OnDecoratorError(
textual._on.OnDecoratorError: The message class must have a 'control' to match with the on decorator

Textual Diagnostics

Versions

Name Value
Textual 0.26.0
Rich 13.3.3

Python

Name Value
Version 3.10.9
Implementation CPython
Compiler GCC 9.4.0
Executable /home/dave/.pyenv/versions/3.10.9/envs/ng/bin/python3.10

Operating System

Name Value
System Linux
Release 5.14.0-1059-oem
Version #67-Ubuntu SMP Mon Mar 13 14:22:10 UTC 2023

Terminal

Name Value
Terminal Application vscode (1.78.2)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=95, height=59
legacy_windows False
min_width 1
max_width 95
is_terminal True
encoding utf-8
max_height 59
justify None
overflow None
no_wrap False
highlight None
markup None
height None
@Textualize Textualize deleted a comment from github-actions bot May 24, 2023
@davep
Copy link
Contributor

davep commented May 24, 2023

This should be addressed by #2602.

@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

@davep
Copy link
Contributor

davep commented May 25, 2023

Just double-checked and #2602 does fix this. Thanks again for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants