Last active
December 25, 2015 11:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'll need a kv file like the following to load the test: https://gist.github.com/bkuri/6966975