Sunday, August 15, 2021

kv 33 textinput progressbar



#progressbar.kv
ProgressBarWidget:
    BoxLayout:
        size: root.width, root.height
        orientation: "vertical"
        BoxLayout:
            TextInput:
                size_hint: 1, None
                height: "120dp"
                pos_hint: {"center_y": 0.5}
                id: text1
                multiline: False
                on_text_validate: root.text_input(self)
                input_filter: "float"
                text: "50"
                font_size: "100dp"
            Label:
                text: root.text_1
                font_name: "font/LCD.ttf"
                font_size: "100dp"
        ProgressBar:
            max: 100
            value: float(root.text_1)

----------------------
#progressbar.py
from kivy.app import App
from kivy.properties import StringProperty
from kivy.uix.widget import Widget


class ProgressBarWidget(Widget):
    text_1 = StringProperty("50")

    def text_input(self, widget):
        self.text_1 = widget.text


class ProgressBarApp(App):
    pass


ProgressBarApp().run()

reference:

No comments:

Post a Comment