1 year ago

#369845

test-img

Kamel Menazeli

Bad:freezing app while using loop in kivy

i have problem when i use loop in kivy app to show update value for loop, so when i run app and press toggle button to start showing last value of loop i program crash.
this is code:

*.py

from kivy.app import App
from kivy.clock import Clock
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import StringProperty
from random import randint


class ShowLoopValueInterface(BoxLayout):
    ToggleButton_label = StringProperty("normal")
    Label_text_value = StringProperty("normal")

    def togglebutton_on_state(self, widget):
        if widget.state == "down":
            self.ToggleButton_label = "down"
            # self.to_text_value()
            Clock.schedule_interval(self.to_text_value, 0.5)
        else:
            self.ToggleButton_label = "normal"
    def to_text_value(self, _):
    # def to_text_value(self):
        while True:
            self.Label_text_value = str(randint(0, 100))


class ShowLoopValueApp(App):
    pass


ShowLoopValueApp().run()

*.kv

ShowLoopValueInterface:
<ShowLoopValueInterface>:
    orientation: "vertical"
    ToggleButton:
        text: root.ToggleButton_label
        on_state: root.togglebutton_on_state(self)
    Label:
        text: root.Label_text_value

python

firebase

python-requests

kivy

boxlayout

0 Answers

Your Answer

Accepted video resources