Why is not possible to assign a function to the left soft key (Options)? If yes, how to? I've the same problem with the key_codes module: EKeyLeftSoftkey is not recognized. Thanks for you help.
Why is not possible to assign a function to the left soft key (Options)? If yes, how to? I've the same problem with the key_codes module: EKeyLeftSoftkey is not recognized. Thanks for you help.
You can detect when the left softkey is pressed with the keycapture module and call a function. See this thread and the PyS60 Library Reference for details.
Why the EKeyLeftSoftkey keypress function does not assign the "choise" selection list at the execution?Code:import appuifw import e32 import keycapture from key_codes import * def choise(): index = appuifw.selection_list(choices=L , search_field=1) if index == 0: appuifw.app.body=appuifw.Text("E32USER-CBase (63)") appuifw.app.exit_key_handler=choise if index == 1: appuifw.app.body=appuifw.Text("E32USER-CBase (69)") appuifw.app.exit_key_handler=choise L = [(u'E32USER-CBase 63'),(u'E32USER-CBase 69')] canvas = appuifw.Canvas() appuifw.app.body = canvas def cb_capture(key): if key == EKeyRightSoftkey: print "Left softkey pressed" if key == EKeyLeftSoftkey: choise capturer = keycapture.KeyCapturer(cb_capture) capturer.keys = (EKeyRightSoftkey, EKeyLeftSoftkey) capturer.start() def exit_key_handler(): app_lock.signal() appuifw.app.set_exit() app_lock = e32.Ao_lock() appuifw.app.exit_key_handler = exit_key_handler app_lock.wait()
You have to call the function with the parantheses (marked in red):
Code:import appuifw import e32 import keycapture from key_codes import * def choise(): index = appuifw.selection_list(choices=L , search_field=1) if index == 0: appuifw.app.body=appuifw.Text("E32USER-CBase (63)") appuifw.app.exit_key_handler=choise if index == 1: appuifw.app.body=appuifw.Text("E32USER-CBase (69)") appuifw.app.exit_key_handler=choise L = [(u'E32USER-CBase 63'),(u'E32USER-CBase 69')] canvas = appuifw.Canvas() appuifw.app.body = canvas def cb_capture(key): if key == EKeyRightSoftkey: print "Left softkey pressed" if key == EKeyLeftSoftkey: choise() capturer = keycapture.KeyCapturer(cb_capture) capturer.keys = (EKeyRightSoftkey, EKeyLeftSoftkey) capturer.start() def exit_key_handler(): app_lock.signal() appuifw.app.set_exit() app_lock = e32.Ao_lock() appuifw.app.exit_key_handler = exit_key_handler app_lock.wait()
Thanks for your help. Another doubt is related of the escaping of the parenthesis in text.Code:if index == 0: appuifw.app.body=appuifw.Text("E32USER-CBase (63)") appuifw.app.exit_key_handler=choise
With or without parentheses the selection list is not displayed at keypress.
Last edited by Anime; 2009-02-23 at 21:14.
bind(event_code , callback) seem do not work for callback=choise (selection list)Code:canvas.bind(key_codes.EKeyLeftSoftkey, choise)
Last edited by Anime; 2009-02-23 at 21:51.
Last edited by croozeus; 2009-02-24 at 09:50. Reason: corrected typo
Pankaj Nathani
www.croozeus.com
Can you give an example, please?May be the use of lamda may help?
Pankaj Nathani
www.croozeus.com
It seems not execute the selection list.Code:canvas.bind(key_codes.EKeyLeftSoftkey, lambda: choise())
Last edited by Anime; 2009-02-24 at 10:48.
How I set capturer.start() at every canvas callback?