Skip to content

Instantly share code, notes, and snippets.

@onslauth
Created April 27, 2017 06:39
Show Gist options
  • Save onslauth/8a438168d5867e092bcb054100ec77d5 to your computer and use it in GitHub Desktop.
Save onslauth/8a438168d5867e092bcb054100ec77d5 to your computer and use it in GitHub Desktop.
#:kivy 1.9
# In Kivy language, the widget added last is at the top of the window in terms of Z.
# So to make sure that buttons receive the click event, add them last so they are not
# overridden by the other widgets.
<StartScreen>:
entire_window: entire_window
nav_bar: nav_bar
action_group: action_group
BoxLayout:
id: entire_window
size_hint: 1, 1
orientation: "vertical"
ActionBar:
id: nav_bar
pos_hint: { "top": 1 }
ActionView:
use_separator: False
ActionPrevious:
title: "Demo App"
with_previous: False
ActionButton:
text: "New"
on_release: root.add_button( )
ActionGroup:
id: action_group
text: "Group 1"
mode: "spinner"
ActionGroup:
text: "Group 2"
mode: "spinner"
ActionButton:
font_size: 14
text: "Button 1"
ActionButton:
font_size: 14
text: "Button 2"
BoxLayout:
size: root.size
pos: root.pos
orientation: "vertical"
canvas.before:
Color:
rgba: 0.2, 0.2, 0.2, 1
Rectangle:
pos: self.pos
size: self.size
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.button import Button
from kivy.properties import ObjectProperty, ListProperty, NumericProperty, StringProperty
from kivy.uix.actionbar import ActionButton
class StartScreen( Screen ):
def add_button( self ):
print( "clicked" )
btn = ActionButton( text = "New button" )
self.action_group._dropdown.add_widget( btn )
self.action_group._dropdown.height += btn.height
class DemoApp(App):
def build(self):
sm = ScreenManager()
self.sm = sm
sm.add_widget( StartScreen( name = "start" ) )
return sm
root = None
if __name__ == '__main__':
root = DemoApp( )
root.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment