Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

kivy menu bar

1#:kivy 1.8.0
  2#:import KivyLexer kivy.extras.highlight.KivyLexer
  3#:import Factory kivy.factory.Factory
  4
  5<ActionSpinnerOptions@SpinnerOption>
  6    background_color: .4, .4, .4, 1
  7
  8<ActionSpinner@Spinner+ActionItem>
  9    canvas.before:
 10        Color:
 11            rgba: 0.128, 0.128, 0.128, 1
 12        Rectangle:
 13            size: self.size
 14            pos: self.pos
 15    border: 27, 20, 12, 12
 16    background_normal: 'atlas://data/images/defaulttheme/action_group'
 17    option_cls: Factory.ActionSpinnerOptions
 18
 19<ActionDropdown>:
 20    on_size: self.width = '220dp'
 21
 22<ShowcaseScreen>:
 23    ScrollView:
 24        do_scroll_x: False
 25        do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16))
 26        AnchorLayout:
 27            size_hint_y: None
 28            height: root.height if root.fullscreen else max(root.height, content.height)
 29            GridLayout:
 30                id: content
 31                cols: 1
 32                spacing: '8dp'
 33                padding: '8dp'
 34                size_hint: (1, 1) if root.fullscreen else (.8, None)
 35                height: self.height if root.fullscreen else self.minimum_height
 36
 37
 38BoxLayout:
 39    orientation: 'vertical'
 40
 41    canvas.before:
 42        Color:
 43            rgb: .6, .6, .6
 44        Rectangle:
 45            size: self.size
 46            source: 'data/background.png'
 47
 48    ActionBar:
 49
 50        ActionView:
 51            id: av
 52            ActionPrevious:
 53                with_previous: (False if sm.current_screen.name == 'button' else True) if sm.current_screen else False
 54                title: 'Showcase' + ('' if not app.current_title else ' - {}'.format(app.current_title))
 55                on_release: app.go_hierarchy_previous()
 56
 57            ActionSpinner:
 58                id: spnr
 59                important: True
 60                text: 'Jump to Screen'
 61                values: app.screen_names
 62                on_text:
 63                    if sm.current != args[1]:
 64                    idx = app.screen_names.index(args[1]);
 65                    app.go_screen(idx)
 66            ActionToggleButton:
 67                text: 'Toggle sourcecode'
 68                icon: 'data/icons/bug.png'
 69                on_release: app.toggle_source_code()
 70            ActionButton:
 71                text: 'Previous screen'
 72                icon: 'data/icons/chevron-left.png'
 73                on_release: app.go_previous_screen()
 74
 75            ActionButton:
 76                text: 'Next screen'
 77                icon: 'data/icons/chevron-right.png'
 78                on_release: app.go_next_screen()
 79                important: True
 80
 81    ScrollView:
 82        id: sv
 83        size_hint_y: None
 84        height: 0
 85
 86        CodeInput:
 87            id: sourcecode
 88            lexer: KivyLexer()
 89            text: app.sourcecode
 90            readonly: True
 91            size_hint_y: None
 92            font_size: '12sp'
 93            height: self.minimum_height
 94
 95    ScreenManager:
 96        id: sm
 97        on_current_screen:
 98            spnr.text = args[1].name
 99            idx = app.screen_names.index(args[1].name)
100            if idx > -1: app.hierarchy.append(idx)
Source by kivy.org #
 
PREVIOUS NEXT
Tagged: #kivy #menu #bar
ADD COMMENT
Topic
Name
1+5 =