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

Badge #1593

Closed
einfall opened this issue Jan 22, 2024 · 2 comments
Closed

Badge #1593

einfall opened this issue Jan 22, 2024 · 2 comments
Labels
Status: Needs analysis Issue needs to be analyzed if it's real

Comments

@einfall
Copy link

einfall commented Jan 22, 2024

Right from the Badge is a white square and the Badge isn't round after set a new text.

from kivy.lang import Builder
from kivymd.app import MDApp

KV = '''
MDScreen:
    md_bg_color: self.theme_cls.backgroundColor

    MDFabButton:
        id: button_images
        style: 'small'
        icon: 'panorama-variant-outline'
        pos_hint: {'center_x': .5, 'center_y': .4}

        MDBadge:
            id: button_images_badge
            text: ""
            #opacity: 0
                                
    MDButton:
        pos_hint: {'center_x': .5, 'center_y': .5}
        on_press: app.plus()

        MDButtonIcon:
            icon: "plus-thick"

        MDButtonText:
            text: "PLUS"

    MDButton:
        pos_hint: {'center_x': .5, 'center_y': .6}
        on_press: app.zero()

        MDButtonIcon:
            icon: "numeric-0-circle-outline"

        MDButtonText:
            text: "ZERO"
'''

from kivy.core.window import Window
Window.size = (400, 600)
Window.top = 150
Window.left = 850

class Example(MDApp):
    def build(self):
        return Builder.load_string(KV)

    def on_start(self):
        super().on_start()
        self.app = MDApp.get_running_app()
        self.count = 0
        self.app.root.ids.button_images_badge.opacity = 0

    def zero(self):
        self.count = 0
        self.update_badge_icon()

    def plus(self):
        self.count += 1
        self.update_badge_icon()

    def update_badge_icon(self):
        if self.count > 0:
            self.app.root.ids.button_images_badge.text = str(self.count)
            self.app.root.ids.button_images_badge.opacity = 1
        else:
            self.app.root.ids.button_images_badge.opacity = 0


Example().run()

badge

badge.mp4
@HeaTTheatR HeaTTheatR added the Status: Needs analysis Issue needs to be analyzed if it's real label Jan 22, 2024
@einfall
Copy link
Author

einfall commented Jan 23, 2024

The white square is fixed. But the red Badge isn't round.

@HeaTTheatR
Copy link
Member

Set radius

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs analysis Issue needs to be analyzed if it's real
Projects
None yet
Development

No branches or pull requests

2 participants