前提
プログラミング初心者です。
Pythonでタイマーを作りたいのですが、TimerLabelのtextの変更が反映されない問題で困っています。
実現したいこと
指定した秒数分を計るタイマー
発生している問題・エラーメッセージ
TimerLabelのtextの変更が反映されない。
該当のソースコード
Python
1from kivy.app import App 2from kivy.uix.button import Button 3from kivy.uix.label import Label 4from kivy.uix.boxlayout import BoxLayout 5from kivy.uix.textinput import TextInput 6from kivy.clock import Clock 7 8class TimerLabel(Label): 9 counter = None 10 time = 0 11 text = str(time) 12 def start_timer(self): 13 self.counter = Clock.schedule_interval(self.count, 1) 14 def count(self, dt): 15 if self.time != 0: 16 self.text = str(self.time) 17 self.time -= 1 18 else: 19 self.counter.cancel() 20 self.parent.children[0].disabled = False 21 22class TimerTextIput(TextInput): 23 def on_text_validate(self): 24 self.parent.parent.children[1].time = int(self.text) 25 26class TimerButton(Button): 27 def on_press(self): 28 self.parent.parent.children[1].start_timer() 29 self.parent.disabled = True 30 31class TimerApp(App): 32 def build(self): 33 root = BoxLayout(orientation="vertical") 34 lower_box = BoxLayout() 35 lower_box.add_widget(TimerButton(text = "start")) 36 lower_box.add_widget(TimerTextIput(multiline = False)) 37 root.add_widget(TimerLabel()) 38 root.add_widget(lower_box) 39 return root 40 41TimerApp().run()
試したこと
textの値は変わっていると思われますが、それが画面上に反映されません。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/11/27 15:38