how to display unicode in a Label in Tkinter

A

Ali

I was wondering how one would go about displaying unicode in a Label
object in a Tkinter window. I am trying to display text in another
language. Please help.
 
E

Eric Brunel

Ali said:
I was wondering how one would go about displaying unicode in a Label
object in a Tkinter window. I am trying to display text in another
language. Please help.

Just put it in a Unicode string or in a raw string encoded in UTF-8 and you
should be going:

(The code above supposes your default encoding is iso8859-1, a.k.a latin-1;
otherwise, you can do: s = '\xe0\xe9\xe8\xf9: \xe7a marche!')

HTH
 
A

Ali

Eric Brunel said:
Just put it in a Unicode string or in a raw string encoded in UTF-8 and you
should be going:


(The code above supposes your default encoding is iso8859-1, a.k.a latin-1;
otherwise, you can do: s = '\xe0\xe9\xe8\xf9: \xe7a marche!')

HTH

So how I write in Arabic?
 
E

Eric Brunel

Ali said:
So how I write in Arabic?

The general answer would be to use the unicode codes for the various characters
you use, e.g.:

If you want to do that, you'll find
http://www.unicode.org/versions/Unicode4.0.0/bookmarks.html very useful
(especially section 8 in your case). But it's quite hard to type characters this
way...

There must be another simpler way, based on the standard encoding used when
using Arabic characters. But I don't know this encoding, so I cannot help you
much here. I also don't know how you can input these characters in a computer
(especially in a source file, where the character flow is from left to right)

So I can only return the question: how do *you* usually input Arabic characters
in a source file? Knowing that and the encoding you use, putting Arabic text in
Tkinter labels won't be difficult at all.

HTH
 
M

Matthias Huening

(e-mail address removed) (Ali) wrote in

So how I write in Arabic?

For Arabic you'll probably use Unicode (in which case you can just use
the text in Tkinter) or you'll have tekst encoded as 'iso8859-6'. Then
you have to use something like:
Hope this helps.
Matthias
 
J

Jeff Epler

So how I write in Arabic?

You're unlikely to get anything satisfactory. Tk doesn't do
right-to-left text layout, and it does character-at-a-time drawing which
means you won't get the proper linking between the characters.

I don't know if this bad news is out of date by now, but it certainly
applies to Tk 8.2 and 8.3 on Unix and Windows.

Here's some related advice from the tcl/tk wiki:
http://wiki.tcl.tk/699
but you have to have the stomach to read tcl code.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBIfI7Jd01MZaTXX0RAu0/AJ4ud3E6IpkbcRO3iFsV+Uj2shAd2ACfZmxC
j4XXU9v+wDApEj++b5PQ2rI=
=2KEB
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top