Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Inputing non-ascii characters

My mobile phone (6600) doesn't have a Thai input method.
(You can buy a special software to do it)
After a lot of my thought experiments, I got an easy
example from my friend on this. You do a 2-level popup menu
to let people choose from the character table.
   1  
   2  from appuifw import *
   3  
   4  def thai_input():
   5      first_list = ['  '.join(thai_char[i:i+11]) for i in range(0,77,11)]
   6      y = popup_menu(first_list, u'select Thai char')
   7      if y is not None:
   8          x = popup_menu(thai_char[11*y:11*(y+1)], u'select Thai char')
   9          if x is not None:
  10              t.add(thai_char[11*y + x])
  11  
  12  thai_char = [unichr(0x0e01+i) for i in range(77)]   # 77 thai characters
  13  
  14  app.body = t = Text()
  15  app.menu = [(u'thai', thai_input), (u'clear screen', t.clear)] 
  16  
  17  # wait for user to exit program
  18  import e32      
  19  lock = e32.Ao_lock() 
  20  app.exit_key_handler=lock.signal
  21  lock.wait()


For other language, you can change the unicode offset (0x0e01)
and number of characters (77) to that of your language.
One requirement for this method is that the phone must be
able to display font in your language already.
(I have previously install Thai font on my 6600)
An alternative method to implement this will be manually drawing
your text (combile character from image font file).
I may do that some day.

Using submenu

   1  
   2  appuifw.app.menu = [(u"item 1", item1),
   3    (u"Submenu 1", ((u"sub item 1", subitem1),
   4    (u"sub item 2", subitem2) ))
   5  ]
   6  # item1, subitem1, subitem2 are callback
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS