Last active
March 8, 2021 12:49
-
-
Save gottadiveintopython/fff4fd8332194a43693001475606e794 to your computer and use it in GitHub Desktop.
test Carousel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from kivy.lang import Builder | |
| from kivy.factory import Factory | |
| from kivy.app import runTouchApp | |
| KV_CODE = ''' | |
| <DebugCarousel@Carousel>: | |
| canvas.before: | |
| Clear: | |
| canvas.after: | |
| Clear: | |
| Color: | |
| rgba: 1, 1, 1, 1 | |
| Line: | |
| dash_offset: 8 | |
| dash_length: 2 | |
| rectangle: [*self.pos, *self.size, ] | |
| FloatLayout: | |
| DebugCarousel: | |
| id: carousel | |
| size_hint: .2, .2 | |
| pos_hint: {'center': (.5, .5, ), } | |
| loop: True | |
| ''' | |
| root = Builder.load_string(KV_CODE) | |
| carousel = root.ids.carousel | |
| carousel.bind( | |
| index=lambda __, value: print('index:', value), | |
| current_slide=lambda __, value: print('current_slide:', value), | |
| ) | |
| for i in range(2): | |
| l = Factory.Button(text=str(i), font_size=100) | |
| carousel.add_widget(l) | |
| runTouchApp(root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment