Python 无法使用kivy中的屏幕id访问屏幕
我想要实现的是创建一个简单的应用程序,在不同的屏幕布局中显示当前的天气信息。由于信息在整个布局中保持不变,我将根据在屏幕管理器中运行的计划任务定期更新它们。 我想要实现的是,当从screen Manager执行调度函数时,更新不同屏幕中的变量 为了达到同样的目的,我使用以下方法:Python 无法使用kivy中的屏幕id访问屏幕,python,python-3.x,kivy,kivy-language,Python,Python 3.x,Kivy,Kivy Language,我想要实现的是创建一个简单的应用程序,在不同的屏幕布局中显示当前的天气信息。由于信息在整个布局中保持不变,我将根据在屏幕管理器中运行的计划任务定期更新它们。 我想要实现的是,当从screen Manager执行调度函数时,更新不同屏幕中的变量 为了达到同样的目的,我使用以下方法: App.get_running_App().root.ids.clock_screen 1.= 但有了这一点,我就面临着“KeyError:‘clock_screen1’” kivy文件如下所示 <RootScr
App.get_running_App().root.ids.clock_screen 1.=代码>
但有了这一点,我就面临着“KeyError:‘clock_screen1’”
kivy文件如下所示
<RootScreen>:
transition: FadeTransition()
ClockScreen1:
ClockScreen2:
SettingsScreen:
<ClockScreen1>:
id: clock_screen1
...
<ClockScreen2>:
id: clock_screen2
...
class RootScreen(ScreenManager):
def __init__(self, *args, **kwargs):
super(RootScreen, self).__init__(*args, **kwargs)
Clock.schedule_interval(self.update_time, 1)
def update_time():
print("list of ids")
print(App.get_running_app().root.ids.keys())
App.get_running_app().root.ids.clock_screen1.current_time = "00:00:00"
App.get\u running\u App().root.ids.keys()的输出为空
我得到的确切错误是
list of ids
dict_keys([])
[INFO ] [Base ] Leaving application in progress...
Traceback (most recent call last):
File "kivy/properties.pyx", line 860, in kivy.properties.ObservableDict.__getattr__
KeyError: 'clock_screen1'
During handling of the above exception, another exception occurred:
...
*trace back*
...
File "kivy/properties.pyx", line 863, in kivy.properties.ObservableDict.__getattr__
AttributeError: 'super' object has no attribute '__getattr__'
有人能帮我找出这是怎么回事吗
非常感谢