Hello,

i am trying to create an application with 2 tabs and the application hangs when running on the mobile phone. I am not familiar with Threading on S60 but i think that per Python, i am correctly using them. Here is the code:

Code:
import threading, appuifw, e32, random, time
       
class DummyThread(threading.Thread):
    def __init__(self, color, id):
        threading.Thread.__init__(self)
        self.logScreen = appuifw.Text()
        self.logScreen.color = color
        self.id = id
        self.isRunning = True
    
    def logMsg(self, data):
        self.logScreen.add(unicode(data))
    
    def run(self):
        while self.isRunning:
            self.printDummyMsg()
            time.sleep(random.choice(range(5)))
    
    def getLogScreen(self):
        return self.logScreen
    
    def printDummyMsg(self):
        msg = str(self.id) + " - " + str(random.choice(range(50)))
        self.logMsg(msg)
    
    def stop(self):
        self.isRunning = False
       
def switchTabs(index):
    if index == 0:
        appuifw.app.body = log_2.getLogScreen()
    elif index == 1:
        appuifw.app.body = log_1.getLogScreen()

def quit():
    log_1.stop()
    log_2.stop()
    lock.signal()
  
lock = e32.Ao_lock()
appuifw.exit_key_handler = quit
appuifw.app.screen = "normal"
appuifw.app.set_tabs([u"Log 1", u"Log 2"], switchTabs)
log_1 = DummyThread(0xFF0000, 1)
log_1.start()
log_2 = DummyThread(0x0000FF, 2)
log_2.start()
appuifw.app.body = log_2.getLogScreen()
lock.wait()
Here is the same code but without the tabs business and this runs on the mobile phone:

Code:
import threading, appuifw, e32, random, time
       
class DummyThread(threading.Thread):
    def __init__(self, id):
        threading.Thread.__init__(self)
        self.id = id
        self.isRunning = True
    
    def logMsg(self, data):
        print unicode(data)
    
    def run(self):
        while self.isRunning:
            self.printDummyMsg()
            time.sleep(random.choice(range(5)))
    
    def printDummyMsg(self):
        msg = str(self.id) + " - " + str(random.choice(range(50)))
        self.logMsg(msg)
    
    def stop(self):
        self.isRunning = False
       
def quit():
    log_1.stop()
    log_2.stop()
    lock.signal()
  
lock = e32.Ao_lock()
appuifw.exit_key_handler = quit
appuifw.app.screen = "normal"
log_1 = DummyThread(1)
log_1.start()
log_2 = DummyThread(2)
log_2.start()
lock.wait()
Could anyone help me with understanding the problem and/or with a solution
Thanks