| 19 | |
| 20 | |
| 21 | class ShowcaseApp(App): |
| 22 | |
| 23 | index = NumericProperty(-1) |
| 24 | current_title = StringProperty() |
| 25 | time = NumericProperty(0) |
| 26 | show_sourcecode = BooleanProperty(False) |
| 27 | sourcecode = StringProperty() |
| 28 | screen_names = ListProperty([]) |
| 29 | hierarchy = ListProperty([]) |
| 30 | |
| 31 | def build(self): |
| 32 | self.title = 'hello world' |
| 33 | Clock.schedule_interval(self._update_clock, 1 / 60.) |
| 34 | self.screens = {} |
| 35 | self.available_screens = sorted([ |
| 36 | 'Buttons', 'ToggleButton', 'Sliders', 'ProgressBar', 'Switches', |
| 37 | 'CheckBoxes', 'TextInputs', 'Accordions', 'FileChoosers', |
| 38 | 'Carousel', 'Bubbles', 'CodeInput', 'DropDown', 'Spinner', |
| 39 | 'Scatter', 'Splitter', 'TabbedPanel + Layouts', 'RstDocument', |
| 40 | 'Popups', 'ScreenManager']) |
| 41 | self.screen_names = self.available_screens |
| 42 | curdir = dirname(__file__) |
| 43 | self.available_screens = [join(curdir, 'data', 'screens', |
| 44 | '{}.kv'.format(fn).lower()) for fn in self.available_screens] |
| 45 | self.go_next_screen() |
| 46 | |
| 47 | def on_pause(self): |
| 48 | return True |
| 49 | |
| 50 | def on_resume(self): |
| 51 | pass |
| 52 | |
| 53 | def on_current_title(self, instance, value): |
| 54 | self.root.ids.spnr.text = value |
| 55 | |
| 56 | def go_previous_screen(self): |
| 57 | self.index = (self.index - 1) % len(self.available_screens) |
| 58 | screen = self.load_screen(self.index) |
| 59 | sm = self.root.ids.sm |
| 60 | sm.switch_to(screen, direction='right') |
| 61 | self.current_title = screen.name |
| 62 | self.update_sourcecode() |
| 63 | |
| 64 | def go_next_screen(self): |
| 65 | self.index = (self.index + 1) % len(self.available_screens) |
| 66 | screen = self.load_screen(self.index) |
| 67 | sm = self.root.ids.sm |
| 68 | sm.switch_to(screen, direction='left') |
| 69 | self.current_title = screen.name |
| 70 | self.update_sourcecode() |
| 71 | |
| 72 | def go_screen(self, idx): |
| 73 | self.index = idx |
| 74 | self.root.ids.sm.switch_to(self.load_screen(idx), direction='left') |
| 75 | self.update_sourcecode() |
| 76 | |
| 77 | def go_hierarchy_previous(self): |
| 78 | ahr = self.hierarchy |