Created
August 28, 2013 22:15
-
-
Save inclement/6372048 to your computer and use it in GitHub Desktop.
Kivy scheduling example
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
from kivy.app import App | |
from kivy.uix.widget import Widget | |
from kivy.uix.button import Button | |
from kivy.uix.progressbar import ProgressBar | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.clock import Clock | |
class MainMenu(BoxLayout): | |
def __init__(self, **kwargs): | |
super(MainMenu, self).__init__(**kwargs) | |
self.orientation = 'vertical' | |
btn = Button(text="Start") | |
btn.bind(on_release=self.heavyFunc) | |
self.add_widget(btn) | |
self.pb = ProgressBar(max = 10000) | |
Clock.schedule_interval(self.heavyFunc,1/60.) | |
self.add_widget(self.pb) | |
def heavyFunc(self, dt): | |
self.pb.value += 1 | |
print self.pb.value | |
if self.pb.value >= 10000: | |
Clock.unschedule(self.heavyFunc) | |
class TestApp(App): | |
def build(self): | |
return MainMenu() | |
if __name__ == "__main__": | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment