Skip to content

Instantly share code, notes, and snippets.

@yishenggudou
Created August 8, 2012 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yishenggudou/3294612 to your computer and use it in GitHub Desktop.
Save yishenggudou/3294612 to your computer and use it in GitHub Desktop.
kivy carousel sample
import random
import os
import carousel
from kivy.base import runTouchApp
from kivy.core.window import Window
base_dir = os.path.split(os.path.abspath(__file__))[0]
imgs = [os.path.join(base_dir, 'imgs', img) for img in os.listdir(os.path.join(base_dir, 'imgs')) if os.path.isfile(os.path.join(base_dir, 'imgs', img))]
slider1 = carousel.Carousel(width=800, height=200)
slider1.slides = imgs
slider2 = carousel.Carousel(width=800, height=200, pos=(0, 300))
random.shuffle(imgs)
slider2.slides = imgs
Window.add_widget(slider1)
Window.add_widget(slider2)
# slider3 = carousel.Carousel(width=200, height=600, pos=(0, 0), direction='vertical')
# random.shuffle(imgs)
# slider3.slides = imgs
# slider4 = carousel.Carousel(width=200, height=600, pos=(200, 0), direction='vertical')
# random.shuffle(imgs)
# slider4.slides = imgs
# slider5 = carousel.Carousel(width=200, height=600, pos=(400, 0), direction='vertical')
# random.shuffle(imgs)
# slider5.slides = imgs
# Window.add_widget(slider3)
# Window.add_widget(slider4)
# Window.add_widget(slider5)
runTouchApp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment