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

Broken bindings after 0.61.0 #4533

Closed
mzebrak opened this issue May 21, 2024 · 3 comments
Closed

Broken bindings after 0.61.0 #4533

mzebrak opened this issue May 21, 2024 · 3 comments

Comments

@mzebrak
Copy link

mzebrak commented May 21, 2024

Pre 0.61.0 version (I tested on 0.60.1) such a BINDINGS definition was okay (AFAIK we took it from the docs or examples), but it don't work now.

from __future__ import annotations

from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.screen import Screen
from textual.widgets import Footer, Header, Label


class ScreenBase(Screen):
    def compose(self) -> ComposeResult:
        yield Header()
        yield Label(self.__class__.__name__)
        yield Footer()


class LeaveMeNow(ScreenBase):
    BINDINGS = [
        Binding("escape", "pop_screen", "Back"),
    ]


class DefaultScreen(ScreenBase):
    BINDINGS = [Binding("p", "push_screen('leave_me_now')", "push other screen")]


class MyApp(App):
    SCREENS = {
        "leave_me_now": LeaveMeNow,
    }

    def on_mount(self) -> None:
        self.push_screen(DefaultScreen())
        self.push_screen(LeaveMeNow())


MyApp().run()

Workaround by changing "pop_screen" to "app.pop_screen" fixes that, but I think that's an unexpected behaviour after some recent changes.

Copy link

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

@willmcgugan
Copy link
Collaborator

That is the correct behavior how. See the release notes. https://github.com/Textualize/textual/blob/main/CHANGELOG.md#changed

Copy link

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

2 participants