runner.py is a small file (install it as a library) to make more efficient running processes in PyS60. I kept finding myself writing code like:
exit_flag = 0 def set_exit(): global exit_flag exit flag = 1 appuifw.app.exit_key_handler = set_exit def my_function(): print "I am great!" e32.ao_sleep(1) while not exit_flag: my_function() e32.ao_yield()
Runner automates that. Here's an example:
from runner import Runner def my_function(): print "I am great!" e32.ao_sleep(1) r = Runner(my_function) r.run()
Here's the code for runner.py:
import appuifw import e32 class Runner(object): def __init__(self, to_run): appuifw.app.exit_key_handler = self.set_exit self.exit_flag = 0 self.to_run = to_run def run(self): while not self.exit_flag: self.to_run() e32.ao_yield() def set_exit(self): self.exit_flag = 1