New to Kivy, but absolutely loving it. I've been toying with some of the different layouts and I'm trying to put an accordion on the second page of a carousel. The first page of the carousel is just a label and it works fine.

The problem is when I slide to the second page the accordion is not lined up like it should be. It's very zoomed in and the labels are off to the side. I can't even see all the items in it. I've attached a picture of the outcome.

Here is my code...

from kivy.uix.accordion import Accordion, AccordionItem
from kivy.uix.label import Label
from kivy.app import App
from kivy.factory import Factory
from kivy.uix.carousel import Carousel

class Example1(App):

    def build(self):
        carousel = Carousel(direction='right')
        upcoming = Label(text="This is a boring label")
        carousel.add_widget(upcoming)

        self.testDictionary = {"Test1": "Hello World", "Test2": "This is a test", "Test3": "To See how this formats"}
        root = Accordion(anim_duration=1.5, orientation='vertical')
        for verseLoc, verse in self.testDictionary.iteritems():
            item = AccordionItem(title=verseLoc)
            item.add_widget(Label(text=verse, text_size=(200, None)))
            carousel.add_widget(item)

        return carousel

Example1().run()

How it should look ^How it looks by itself^ A picture of how the accordion ends up looking ^how it looks inside a carousel

有帮助吗?

解决方案

You are adding AccordionItems directly to the carousel. You need to add items to root and outside the for loop add root to the carousel.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top