Skip to content

Commit

Permalink
Added idle function to App class. Allows to perform scheduled operati…
Browse files Browse the repository at this point in the history
…ons every configuration.UPDATE_INTERVAL.
  • Loading branch information
Davide Rosa committed Jun 4, 2015
1 parent da54e77 commit e52cae9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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'])
Expand Down
7 changes: 6 additions & 1 deletion widgets_overview_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e52cae9

Please sign in to comment.