I am trying to use PageLayout in Accordion but its giving me this error when I try to click anywhere. How to make it working.
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
Here is what I have done so far to get this error. accmain.py file
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 file
<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'
Sorry for formatting, am very new to stack overflow and kivy both. All indentations are correct in my files.
I kind of don't understand your problem. It seems to me that either you didn't post your whole code, or made some typo, or have an old version of kivy. On master branch(1.9.2) this code doesn't throw any error and you can list the pages without any problem(of course Label has no background, so it'll overlap):
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.accordion import Accordion
Builder.load_string('''
<RunLiu>:
orientation: "vertical"
AccordionItem:
title: "Item 1"
PageLayout:
Label:
text: "yee"
Label:
text: "ya"
Label:
text: "yas"
AccordionItem:
title: "Item 2"
Label:
text: "hey there"
AccordionItem:
title: "3rd tab"
Label:
text: 'Item 3'
''')
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()