UNew to Tkinter nicodeEncodeError:Japanese

rajasekaran.natarajan at gmail.com rajasekaran.natarajan at gmail.com
Thu Dec 22 04:30:33 EST 2005


Hi friends,

I am writing my Japanese study program and a GUIt.

I am facing a problem in an entry widget where I enter Japanese words.
The entered Japanese word is accessed by the callback function and used
for some processes.

It is working well when I enter english values.
But giving unicodeEncodeError when I try with the Japanese letter.

I tried to decode it by but I am getting unicodeEncodeError.

the snippet is given below

class showex:
...
......
 def make gui
	.....
	....
       self.entStr = StringVar()
        self.entStr.set('Enter a Word Here')

        wordEntry = Entry(self.msgFrame,textvariable=self.entStr)
        #wordEntry.insert(0, 'Enter word Here')
        wordEntry.pack(side=RIGHT)
        wordEntry.focus()
        wordEntry.bind('<Return>',self.search)

    def previous(self):
        if (self.inc > 9):
            self.inc = self.inc -5
        print 'Previous Executed', self.inc

    def next(self):
        self.inc = self.inc + 5
        print 'Next Executed', self.inc

    def search(self):
        word = self.entStr.get()
        word_utf = word.decode('sjis')
        print "Inside search ...", word_utf.encode('utf8')



I tried

>>> word = '調べる'               #some Japanese word in the quotes
>>> word1 = word.decode('sjis')
>>> print word1.encode('utf8')
調べる				#printed the Japanese word correctly

this is working nicely

What am I doing wrong here

I would greatly appreciate any help or suggestion.

Regards

raj




More information about the Python-list mailing list