×

Discussion Board

Results 1 to 1 of 1
  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    PyS60 Ao_Timer and Active Objects/GUI Interaction - Works only less than 4 seconds

    SOLUTION FOUND: It's not timer at all. Problem due to variable scope and lifetimes - correction shown below in red.

    Don't you just love languages without explicit variable declarations....?

    Unable to get Ao_timer to work with callback. Possibly due to something I don't understand about interaction between UI events, Ao_timer, and e32.Ao_lock() wait. Code works for 3 seconds and below, but nothing greater. Seems the timer only works if it expires while the GUI is still active.

    #Running in PyS60 1.4.5 final
    #Emulator S60 5th Edition SDK v 1.0
    import appuifw
    import e32
    #
    aTimer = e32.Ao_timer()
    #Timer setting function
    def menuMain():
    data = appuifw.query(u"Seconds to Sleep?", "number")
    #aTimer = e32.Ao_timer() VARIABLE LIFETIME ENDS WHEN def DONE!!
    global aTimer
    aTimer.after(data, aTimerRings)
    appuifw.note(u"Timer set for " + str(data))
    #e32.ao_yield() ##Does not seem to affect result
    #
    #Timer callback function
    def aTimerRings():
    appuifw.note(u"Ding!!!!", "info")
    #e32.ao_yield() ##Does not seem to affect result
    #
    #Exit key handler
    def exit_key_handler():
    app_lock.signal()
    #
    #Houskeeping
    appuifw.app.screen = "normal"
    appuifw.app.menu = [(u"Main Menu", menuMain)]
    app_lock = e32.Ao_lock()
    t = appuifw.Text()
    appuifw.app.body = t

    #Run the program
    appuifw.app.exit_key_handler = exit_key_handler
    app_lock.wait()
    Last edited by lwh007; 2009-04-26 at 14:09.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×