Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2003

    crash when adding strftime formated time to listbox

    I'm trying to add a string with date and time created with strftime to a listbox. The script crashes with 'SymbianError: [Errno -6] KErrArgument' on emulator and phone (6120c). Any hints?

    import appuifw
    import e32
    import time
    def callback():
    	listbox_index = listbox.current()
    	appuifw.note(u"callback " + str(listbox_index),'info')
    def exit_key_handler():
    #adding a string to listbox works 
    #listbox = appuifw.Listbox([u"02.10.2007 16:36"],callback)
    #adding a formated time string causes an error
    listbox = appuifw.Listbox([time.strftime(u"%d.%m.%Y %H:%M", time.localtime())],callback)
    appuifw.app.body = listbox
    app_lock = e32.Ao_lock()
    appuifw.app.exit_key_handler = exit_key_handler
    if not e32.in_emulator():

  2. #2
    Registered User
    Join Date
    Feb 2006
    Helsinki, Finland

    Re: crash when adding strftime formated time to listbox

    The reason you are getting this error is because the listbox accepts only unicode strings as values

    time.strftime(u"%d.%m.%Y %H:%M", time.localtime())
    '02.10.2007 18:08'
    but we want:
    u'02.10.2007 18:08'

    so we need to convert it to unicode like this:
    unicode(time.strftime(u"%d.%m.%Y %H:%M", time.localtime()))
    u""+time.strftime(u"%d.%m.%Y %H:%M", time.localtime())

    Hope this helps

    Nokia E66
    PyS60 1.4.4 final

  3. #3
    Registered User
    Join Date
    Sep 2003

    Re: crash when adding strftime formated time to listbox

    Thanks for your answer!
    The unicode() command did the trick. I wasn't aware that the return of strftime isn't unicode as it was printed with correct with the print command in the shell.

Similar Threads

  1. SOS!!!!!!!! Problem with adding data to listbox
    By chishti.hameed in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-07-26, 07:05
  2. Log time bug on 3650. Help me please.
    By hemenkap in forum General Development Questions
    Replies: 2
    Last Post: 2005-06-30, 07:18
  3. Creating listbox takes long time?
    By birol.sekerci in forum Symbian User Interface
    Replies: 5
    Last Post: 2004-11-07, 19:27
  4. listbox and model
    By stenlik in forum Symbian
    Replies: 1
    Last Post: 2004-05-27, 07:27
  5. SMS time stamp format with time zone parameter?
    By turunhe in forum General Messaging
    Replies: 1
    Last Post: 2002-06-11, 07:00

Posting Permissions

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