diff --git a/server.py b/server.py index c5d3a887..1668719c 100644 --- a/server.py +++ b/server.py @@ -211,6 +211,7 @@ def update_clients(): ws.send_message('show_window,' + str(id(client.root)) + ',' + repr(client.root)) client.old_root_window = client.root + client.idle() gui_updater(client, client.root) Timer(UPDATE_INTERVAL, update_clients, ()).start() @@ -361,6 +362,11 @@ def instance(self): updateTimerStarted = True Timer(UPDATE_INTERVAL, update_clients, ()).start() + def idle(self): + """ Idle function called every UPDATE_INTERVAL before the gui update. + Usefull to schedule tasks. """ + pass + def do_POST(self): self.instance() varLen = int(self.headers['Content-Length']) diff --git a/widgets_overview_app.py b/widgets_overview_app.py index 0ddfdf00..bfb51ce2 100644 --- a/widgets_overview_app.py +++ b/widgets_overview_app.py @@ -20,7 +20,12 @@ class MyApp(App): def __init__(self, *args): super(MyApp, self).__init__(*args) - + + def idle(self): + """ Usefull function to schedule tasks. + Called every configuration.UPDATE_ITERVAL """ + super(MyApp, self).idle() + def main(self): mainContainer = gui.Widget(600, 530, True, 10)