0

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.

Peter Badida
  • 11,310
  • 10
  • 44
  • 90

1 Answers1

0

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()
Peter Badida
  • 11,310
  • 10
  • 44
  • 90
  • Thank you for answering @KeyWeeUsr. I am using kivy v1.9.1 and python v2.7.6. Still when I run your above code am getting the same error. I tried to update kivy, its saying python-kivy already newest version. Am working on ubuntu 14.04 and am updating kivy from [here](https://kivy.org/docs/installation/installation-linux.html) – Narendra Singh May 11 '16 at 08:04
  • @NarendraSingh [Here](https://kivy.org/docs/installation/installation-linux.html) you go, use nightly builds or download the code from [github](https://github.com/kivy/kivy) and compile it. It says kivy is up-to-date because you installed stable version(1.9.1) and no newer stable is available for now. – Peter Badida May 11 '16 at 08:31
  • Hi @KeyWeeUsr, can you look into this issue as well http://stackoverflow.com/questions/37161075/graph-plot-not-visible-garden-kivy-python Thanks – Narendra Singh May 11 '16 at 11:21
  • Sorry, haven't used garden.graph yet, so I don't know much about it. – Peter Badida May 11 '16 at 12:03
  • ohh ok no problem :) – Narendra Singh May 11 '16 at 13:39