这两天我一直在尝试解决这个问题。我几乎尝试了一切。我检查了我的 ID 10 次,无论它们是否是字符串。他们不是!!我放置了clock.schedule_one方法来延迟初始化,但程序没有在kv文件中定义id。这是代码;这是错误消息;KeyError: 'hasta'During handling of the above exception, another exception occurred:Traceback (most recent call last): File "C:\Users\Melikşah GÜRCÜ\Desktop\md.py", line 162, in <module> DemoApp().run() File "C:\python\lib\site-packages\kivy\app.py", line 855, in run runTouchApp() File "C:\python\lib\site-packages\kivy\base.py", line 504, in runTouchApp EventLoop.window.mainloop() File "C:\python\lib\site-packages\kivy\core\window\window_sdl2.py", line 747, in mainloop self._mainloop() File "C:\python\lib\site-packages\kivy\core\window\window_sdl2.py", line 479, in _mainloop EventLoop.idle() File "C:\python\lib\site-packages\kivy\base.py", line 339, in idle Clock.tick() File "C:\python\lib\site-packages\kivy\clock.py", line 591, in tick self._process_events() File "kivy\_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events File "kivy\_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events File "kivy\_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events File "kivy\_clock.pyx", line 167, in kivy._clock.ClockEvent.tick File "C:\Users\Melikşah GÜRCÜ\Desktop\md.py", line 155, in _press self.root.ids.hasta.text File "kivy\properties.pyx", line 863, in kivy.properties.ObservableDict.__getattr__AttributeError: 'super' object has no attribute '__getattr__'
1 回答
慕容3067478
TA贡献1773条经验 获得超3个赞
class DemoApp(MDApp):
def _press(self, *dt):
print(self.root.get_screen("scr2").ids.hasta.text)
def _doThis(self, *dt):
print(self.root.get_screen("scr2").ids.hasta.text)
添加回答
举报
0/150
提交
取消