-
Notifications
You must be signed in to change notification settings - Fork 826
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
Button.watch_variant does not remove old_variant class #1048
Labels
bug
Something isn't working
Comments
Good catch. Slightly more interactive display of this, allowing watching the classes develop: from textual.app import App, ComposeResult
from textual.widgets import Button, Static
class MyApp( App[None] ):
def compose( self ) -> ComposeResult:
yield Button( "Push Me" )
yield Static( "Push the above!", id="classes" )
def on_button_pressed( self, event: Button.Pressed ) -> None:
event.button.variant = (
"warning" if event.button.variant == "default" else "default"
)
self.query_one( "#classes", Static ).update(
", ".join( event.button.classes )
)
if __name__ == "__main__":
MyApp().run() |
Did we solve your problem? Glad we could help! |
Now fixed for the next release: #1051 Thanks @n-doerrer! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When changing the variant of a Button widget, the new variant gets added to the classes, but the old one is not removed.
Minimal example:
This still displays the button in "warning" style as it has both classes.
I believe the problem is the underscore instead of a dash in the watch_variant method.
https://github.com/Textualize/textual/blob/main/src/textual/widgets/_button.py#L218
textual version 0.2.1
terminal: xterm-256color on linux ubuntu 22.04 (Regolith)
The text was updated successfully, but these errors were encountered: