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

toggle("disabled") was executed by parent widget #5451

Closed
python-and-fiction opened this issue Jan 2, 2025 · 2 comments
Closed

toggle("disabled") was executed by parent widget #5451

python-and-fiction opened this issue Jan 2, 2025 · 2 comments

Comments

@python-and-fiction
Copy link

In following code, when I click button'1' ,its parent widget which is horizontal container runs toggle("disabled") but not button'1'.
But, when I click button'2', button'2' runs toggle("disabled"). Do I miss something? https://textual.textualize.io/guide/actions/#namespaces says Textual will look for action methods in the class where they are defined (App, Screen, or Widget), This makes me confused. Thanks someone who can help me in advance.

from textual.app import App
from textual.widgets import Button
from textual.containers import Horizontal

class MyApp(App):
    def on_mount(self):
        self.widgets = [
            Horizontal(
            Button('1',action='toggle("disabled")'),
            Button('2',action='focused.toggle("disabled")'),
            Button('3')
            ),
            Button('4')
        ]
        self.mount_all(self.widgets)


if __name__ == '__main__':
    app = MyApp()
    app.run()
Copy link

github-actions bot commented Jan 2, 2025

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@python-and-fiction python-and-fiction closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Copy link

github-actions bot commented Jan 2, 2025

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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

No branches or pull requests

1 participant