Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

class Buttons on file button.py are brokе #3

Open
azamtoiri opened this issue Nov 6, 2023 · 0 comments
Open

class Buttons on file button.py are brokе #3

azamtoiri opened this issue Nov 6, 2023 · 0 comments

Comments

@azamtoiri
Copy link

class Buttons(ft.Container, Theme):
    def __init__(self, width, height, title: str, *args, **kwargs):
        #
        self.title = title
        #
        self.text = ft.Text(
            self.title,
            weight="bold",
            color=ft.colors.with_opacity(0.85, Theme.primary_theme),
        )
        #
        kwargs.setdefault("width", width)
        kwargs.setdefault("height", height)
        kwargs.setdefault("ink", True)
        kwargs.setdefault("bgcolor", "#2e2f3e")
        kwargs.setdefault("shape", ft.BoxShape("rectangle"))
        kwargs.setdefault(
            "border",
            ft.border.all(2, ft.colors.with_opacity(0.85, Theme.primary_theme)),
        )
        kwargs.setdefault("border_radius", 4)
        kwargs.setdefault("on_hover", lambda e: self.animate_button(e))
        kwargs.setdefault("alignment", ft.alignment.center)
        kwargs.setdefault("animate", ft.Animation(500, "ease"))
        kwargs.setdefault("content", self.text)

        super().__init__(*args, **kwargs)

    def animate_button(self, e):
        if self.bgcolor == "#2e2f3e":
            self.bgcolor = Theme.primary_theme
            self.text.color = ft.colors.with_opacity(0.95, "white")
        else:
            self.bgcolor = "#2e2f3e"
            self.text.color = ft.colors.with_opacity(0.85, Theme.primary_theme)

        self.update()

problem is animation

kwargs.setdefault("animate", ft.Animation(500, "ease"))
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant