Skip to content

Instantly share code, notes, and snippets.

@sirpercival
Created February 27, 2014 02:38
Show Gist options
  • Save sirpercival/9243273 to your computer and use it in GitHub Desktop.
Save sirpercival/9243273 to your computer and use it in GitHub Desktop.
#:kivy 1.7.2
<MyBox>
orientation: 'vertical'
size_hint: (0.4, 0.1)
Label:
font_size: 32
color: 1, .97, .83, 1
halign: root.alignment
text: root.name
ProgressBar:
max: root.max_val
value: root.current_val
<MyScreen>
enemy: {'name':'Enemy','max':100, 'current':70}
char: {'name':'Character','max':100, 'current':40}
canvas.before:
Color:
rgb: 0, 0, 0
Rectangle:
size: self.size
AnchorLayout:
orientation: 'vertical'
size: root.size
AnchorLayout:
anchor_y: 'top'
size_hint: 1, None
height: 75
MyBox:
anchor_x: 'left'
anchor_y: 'top'
name: root.char['name']
alignment: 'left'
current_val: root.char['current']
max_val: root.char['max']
MyBox:
anchor_x: 'right'
anchor_y: 'top'
name: root.enemy['name']
alignment: 'right'
current_val: root.enemy['current']
max_val: root.enemy['max']
import kivy
kivy.require('1.7.2')
from kivy.app import App
from kivy.base import EventLoop
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import *
from kivy.uix.screenmanager import ScreenManager, Screen, WipeTransition
EventLoop.ensure_window()
class MyBox(BoxLayout):
name = StringProperty('')
alignment = StringProperty('center')
current_val = NumericProperty(100)
max_val = NumericProperty(100)
class MyScreen(Screen):
enemy = DictProperty(None)
char = DictProperty(None)
class MyApp(App):
def build(self):
self.screen_manager = ScreenManager(transition = WipeTransition())
self.screen_manager.add_widget(MyScreen(name='menu'))
return self.screen_manager
if __name__ == '__main__':
MyApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment