Using non-ASCII characters in Tkinter

Nitram15

Pro Libertate!
Joined
Sep 15, 2009
Messages
1,855
Location
Hungary
Hello!

I'm writing python programs and using the built-in GUI Tkinter and tkFileDialog modules.
Everything works well, and the program is very handy now (it is a HTML editor btw) but as I'm Hungarian, I most likely want to use the ISO-1899-16 character set. But if I want to save the text in the editor, I get an error message that non-ASCII characters are Not supported. Well, I don't think so. I'm using special Hungarian characters (öüóűőúéáí) in other Tkinter widgets(buttons, menus etc.) and they shown good, so I think there is a solution for this too. I hope someone who is expert in Tkinter (and/or Python) can help.:)

AND before you say, (just do not have any confuse) of course I wrote # -*- coding: cp1250 -*- in the beginning but it does nothing.:sad:

By the way, I'm using Windows XP Service Pack 2, and the program has been written in Python 2.6 (this is why I'm writing Tkinter and not tkinter. as far as I know, 3.0 uses tkinter module with lowercase "T")

Thanks!
Nitram
 
Well, seemingly nobody answered I have another fact. This is the complete error message when I want to save the file with tkFileDialog using non-ASCII characters:

UnicodeEncodeError: 'ascii' codec can't encode characters in position *something*: ordinal not in range(128)

I tried encoding too, but didn't have too much luck yet. :/
 
It is quite funny to speak with myself but if anyone who know something about Tkinter, c'mon help me!!!

I tried EVERYTHING!

Tried to use try-except-else but didn't work either.
Also tried to use separate button widgets with the insert method, so if clicked on, it will insert an accented character to the text widget. It did insert it, but got the same error.

I'm not waiting to help me with only-Hungarian characters! I can't even write down 'é' which can be French too, not only Hungarian. There must be a solution!!!!!!
 
I don't think people here very much use that ... Maybe you could find a forum especially for that as someone there might be able to help you more.
 
@Padma: Yes I tried. I also tried to put it under every class, definition etc. Didn't work.
And about the encoding, I also tried the encode method, and didn't work either.

@aimeeandbeatles: You're right, that have no use. It only works with console programs not with Tkinter sadly. I hope they will correct that in the next Python version. (I tried 3.2 too, and converted my program to compatible with it, and it didn't work, so I think I give this up now)

But, at least the program works with Unicode characters so I don't think I have a problem. I can create english websites, yay!

Thanks for the replies btw. :)
 
Back
Top Bottom