アコーディオンで PageLayout を使用しようとしていますが、どこかをクリックしようとするとこのエラーが発生します。それを機能させる方法。
Traceback (most recent call last):
File "accmain.py", line 19, in <module>
LiuApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 828, in run
runTouchApp()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 487, in runTouchApp
EventLoop.window.mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 619, in mainloop
self._mainloop()
File "/usr/lib/python2.7/dist-packages/kivy/core/window/window_sdl2.py", line 362, in _mainloop
EventLoop.idle()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 330, in idle
self.dispatch_input()
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 315, in dispatch_input
post_dispatch_input(*pop(0))
File "/usr/lib/python2.7/dist-packages/kivy/base.py", line 221, in post_dispatch_input
listener.dispatch('on_motion', etype, me)
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/core/window/__init__.py", line 1034, in on_motion
self.dispatch('on_touch_up', me)
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/core/window/__init__.py", line 1070, in on_touch_up
if w.dispatch('on_touch_up', touch):
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/uix/widget.py", line 454, in on_touch_up
if child.dispatch('on_touch_up', touch):
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/uix/widget.py", line 454, in on_touch_up
if child.dispatch('on_touch_up', touch):
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/uix/widget.py", line 454, in on_touch_up
if child.dispatch('on_touch_up', touch):
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/uix/widget.py", line 454, in on_touch_up
if child.dispatch('on_touch_up', touch):
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/uix/widget.py", line 454, in on_touch_up
if child.dispatch('on_touch_up', touch):
File "_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:7146)
File "/usr/lib/python2.7/dist-packages/kivy/uix/pagelayout.py", line 201, in on_touch_up
return self.children[-self.page + 1].on_touch_up(touch)
IndexError: list index out of range
このエラーを取得するためにこれまでに行ったことは次のとおりです。 accmain.py ファイル
from kivy.app import App
from kivy.uix.accordion import Accordion
class RunLiu(Accordion):
def __init__(self, **kwargs):
super(RunLiu, self).__init__(**kwargs)
class LiuApp(App):
def build(self):
root = RunLiu()
return root
if __name__ == "__main__":
LiuApp().run()`
liu.kv ファイル
<RunLiu>:
orientation: "vertical"
AccordionItem:
title: "Item 1"
PageLayout:
Label:
text: "yee"
AccordionItem:
title: "Item 2"
Label:
text: "hey there"
AccordionItem:
title: "3rd tab"
Label:
text: 'Item 3'
フォーマットして申し訳ありませんが、スタックオーバーフローとkivyの両方に非常に慣れていません。私のファイルではすべてのインデントが正しいです。