Skip to content

Instantly share code, notes, and snippets.

@bkuri
Last active December 25, 2015 11:09
Show Gist options
  • Save bkuri/6966917 to your computer and use it in GitHub Desktop.
Save bkuri/6966917 to your computer and use it in GitHub Desktop.
My dashboard code. You need a layout file such as this one to load a sample set: https://gist.github.com/bkuri/6966975
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from kivy.animation import Animation
from kivy.app import App
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.properties import ObjectProperty, StringProperty
from kivy.uix.floatlayout import FloatLayout
from gauge import Gauge
# only used when testing
from random import random
EASING = 'linear'
LAYOUT = 'no_rings'
TIME = 1./10.
class Dashboard(FloatLayout):
gauges = ObjectProperty(None)
def __init__(self, **kwargs):
super(Dashboard, self).__init__(**kwargs)
def test(self, *args):
for gauge in self.gauges:
value = round(random() * gauge.max)
anim = Animation(value=value,duration=TIME,t=EASING)
anim.start(gauge)
class MainApp(App):
def build(self):
dash = Dashboard()
Clock.schedule_interval(dash.test, TIME)
return dash
if __name__ == "__main__":
try:
Builder.load_file('lib/layouts/%s.kv' % LAYOUT)
except e:
print 'error loading layout "%s"' % LAYOUT
finally:
MainApp().run()
@bkuri
Copy link
Author

bkuri commented Oct 13, 2013

You'll need a kv file like the following to load the test: https://gist.github.com/bkuri/6966975

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment