猿问

当我尝试访问屏幕 ID 时,“super”对象没有属性“__getattr__”

这两天我一直在尝试解决这个问题。我几乎尝试了一切。我检查了我的 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__'


斯蒂芬大帝
浏览 106回答 1
1回答

慕容3067478

class DemoApp(MDApp):&nbsp; &nbsp; def _press(self, *dt):&nbsp; &nbsp; &nbsp; &nbsp; print(self.root.get_screen("scr2").ids.hasta.text)&nbsp; &nbsp; def _doThis(self, *dt):&nbsp; &nbsp; &nbsp; &nbsp; print(self.root.get_screen("scr2").ids.hasta.text)
随时随地看视频慕课网APP

相关分类

Python
我要回答