Skip to content

Commit e52cae9

Browse files
author
Davide Rosa
committed
Added idle function to App class. Allows to perform scheduled operations every configuration.UPDATE_INTERVAL.
1 parent da54e77 commit e52cae9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def update_clients():
211211
ws.send_message('show_window,' + str(id(client.root)) + ',' + repr(client.root))
212212

213213
client.old_root_window = client.root
214+
client.idle()
214215
gui_updater(client, client.root)
215216
Timer(UPDATE_INTERVAL, update_clients, ()).start()
216217

@@ -361,6 +362,11 @@ def instance(self):
361362
updateTimerStarted = True
362363
Timer(UPDATE_INTERVAL, update_clients, ()).start()
363364

365+
def idle(self):
366+
""" Idle function called every UPDATE_INTERVAL before the gui update.
367+
Usefull to schedule tasks. """
368+
pass
369+
364370
def do_POST(self):
365371
self.instance()
366372
varLen = int(self.headers['Content-Length'])

widgets_overview_app.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ class MyApp(App):
2020

2121
def __init__(self, *args):
2222
super(MyApp, self).__init__(*args)
23-
23+
24+
def idle(self):
25+
""" Usefull function to schedule tasks.
26+
Called every configuration.UPDATE_ITERVAL """
27+
super(MyApp, self).idle()
28+
2429
def main(self):
2530
mainContainer = gui.Widget(600, 530, True, 10)
2631

0 commit comments

Comments
 (0)