Hi Ken,
Sorry, here's the code, which seems to be working:
Code:
import e32
import time
import thread
import appuifw
e32.ao_yield()
class Test:
def __init__(self):
self.lock = e32.Ao_lock()
appuifw.app.exit_key_handler = self.abort
appuifw.app.body = appuifw.Text()
appuifw.app.body.set(u"App started")
appuifw.app.menu = [(u"Exit", self.abort)]
thread.start_new_thread(self.writeToFile, ())
# enter loop to prevent finishing the app
self.loop()
def loop(self):
self.keepRunning = True
while self.keepRunning:
self.refresh()
self.lock.wait()
def refresh(self):
# update UI if necessary
appuifw.app.body.set(u"App running: " + time.strftime("%H:%M:%S\n"))
def writeToFile(self):
self.keepRunning = True
while self.keepRunning:
self.output = open("c:\\tmp\\output.txt", "a")
self.output.write(time.strftime("%H:%M:%S\n"))
self.output.close()
time.sleep(5)
def abort(self):
self.keepRunning = False
appuifw.app.exit_key_handler = None
self.lock.signal()
################
def main():
Test()
if __name__ == "__main__":
main()
I'm not sure how elegant this is.... 
One thing I forgot was putting the main application in a loop. I'm also wondering whether UI changes will be processed and visible in this way.
Cheers,
Berco