Jason Trieu
Jason Trieu

Reputation: 1

kivy carousel has no attribute load_next

I am new to kivy and still kind of a beginner in python. I am trying to create a carousel of texts that infinitely loops every 5 seconds. Right now I am running into this error. I've tried printing the attribute but it seems to be not available. I have kivy 1.10.0 with python 2.7.12

AttributeError: 'Carousel' object has no attribute 'load_next'

Here is the code I have so far:

from kivy.uix.widget import Widget
from kivy.app import App
from kivy.factory import Factory
from kivy.clock import Clock
from kivy.uix.carousel import Carousel

class MirrorApp(App):

    def build(self):
        carousel = Carousel(direction='right', loop=True)
        for i in range(0,10):
            text = Factory.Label(text=str(i))
            carousel.add_widget(text)

        Clock.schedule_interval(carousel.load_next, 5)
        return carousel

if __name__ == '__main__':
    MirrorApp().run()

Upvotes: 0

Views: 232

Answers (1)

ikolim
ikolim

Reputation: 16031

I added the following codes, replaced "range(0, 10)" to range(10), and ran your app without problem on Ubuntu 16.04 LTS and Python3.5, and Python 2.7.12.

import kivy
kivy.require('1.10.0')
...
    for i in range(10):

main.py

import kivy
kivy.require('1.10.0')

from kivy.app import App
from kivy.factory import Factory
from kivy.clock import Clock
from kivy.uix.carousel import Carousel


class MirrorApp(App):

    def build(self):
        carousel = Carousel(direction='right', loop=True)
        for i in range(10):
            text = Factory.Label(text=str(i))
            carousel.add_widget(text)

        Clock.schedule_interval(carousel.load_next, 5)
        return carousel

if __name__ == '__main__':
    MirrorApp().run()

Output

enter image description here

enter image description here

Upvotes: 1

Related Questions