Created
June 6, 2013 19:06
-
-
Save abhijangda/5724034 to your computer and use it in GitHub Desktop.
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.app import App | |
| from kivy.uix.floatlayout import FloatLayout | |
| from kivy.properties import ObjectProperty | |
| from kivy.lang import Builder | |
| from kivy.uix import actionbar | |
| Builder.load_string(''' | |
| <RootWidget>: | |
| action_bar: _action | |
| carousel: carousel | |
| ActionBar: | |
| id: _action | |
| size_hint: 1,0.1 | |
| pos_hint: {'top':1} | |
| ActionView: | |
| use_separator: True | |
| ActionPrevious: | |
| title: 'Slide 1' | |
| with_previous: False | |
| ActionOverflow: | |
| disabled: True | |
| ActionButton: | |
| text: 'Go To Slide 2' | |
| on_release: carousel.index = 1 | |
| ActionButton: | |
| text: 'Go To Slide 3' | |
| on_release: carousel.index = 2 | |
| Carousel: | |
| id: carousel | |
| pos_hint: {'top': 0.9} | |
| on_index: root.on_index(*args) | |
| Button: | |
| text: 'Slide one' | |
| Button: | |
| text: 'Slide Two' | |
| Button: | |
| text: 'Slide three' | |
| ''') | |
| class RootWidget(FloatLayout): | |
| cont1 = ObjectProperty(None) | |
| cont2 = ObjectProperty(None) | |
| action_bar = ObjectProperty(None) | |
| carousel = ObjectProperty(None) | |
| def __init__(self, **kwargs): | |
| super(RootWidget, self).__init__(**kwargs) | |
| self.cont1 = actionbar.ContextualActionView( | |
| action_previous = actionbar.ActionPrevious(title='Go Back')) | |
| self.cont2 = actionbar.ContextualActionView( | |
| action_previous = actionbar.ActionPrevious(title='Go Back')) | |
| self.action_bar.bind(on_previous=self.on_previous) | |
| def on_index(self, instance, value): | |
| if value == 2: | |
| self.action_bar.add_widget(self.cont2) | |
| elif value == 1: | |
| self.action_bar.add_widget(self.cont1) | |
| def on_previous(self, *args): | |
| self.carousel.load_previous() | |
| class MainApp(App): | |
| def build(self): | |
| return RootWidget() | |
| if __name__ == '__main__': | |
| MainApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment