Pārlūkot izejas kodu

update ui.badge

Falko Schindler 2 gadi atpakaļ
vecāks
revīzija
0831a42103
2 mainītis faili ar 7 papildinājumiem un 12 dzēšanām
  1. 6 12
      nicegui/elements/badge.py
  2. 1 0
      nicegui/ui.py

+ 6 - 12
nicegui/elements/old/badge.py → nicegui/elements/badge.py

@@ -1,11 +1,8 @@
-import justpy as jp
-
-from ..binding import BindableProperty, BindTextMixin
-from .element import Element
+from ..binding import BindTextMixin
+from ..element import Element
 
 
 class Badge(Element, BindTextMixin):
-    text = BindableProperty()
 
     def __init__(self, text: str = '', *,
                  color: str = 'blue', text_color: str = 'white', outline: bool = False) -> None:
@@ -19,11 +16,8 @@ class Badge(Element, BindTextMixin):
         :param text_color: overrides text color (if needed); color name from the Quasar Color Palette (default: "white")
         :param outline: use 'outline' design (colored text and borders only) (default: False)
         """
-        view = jp.QBadge(label=text, color=color, text_color=text_color, outline=outline, temp=True)
-        super().__init__(view)
-
-        self.text = text
-        self.bind_text_to(self.view, 'label')
-
-    def set_text(self, text: str) -> None:
+        super().__init__('q-badge')
         self.text = text
+        self._props['color'] = color
+        self._props['text_color'] = text_color
+        self._props['outline'] = outline

+ 1 - 0
nicegui/ui.py

@@ -1,3 +1,4 @@
+from .elements.badge import Badge as badge
 from .elements.button import Button as button
 from .elements.card import Card as card
 from .elements.card import CardActions as card_actions