how to display unicode in a Label in Tkinter

Ali alikakakhel3 at hotmail.com
Mon Aug 16 18:37:21 EDT 2004


Eric Brunel <eric_brunel at despammed.com> wrote in message news:<cfpop0$jlt$1 at news-reader5.wanadoo.fr>...
> Ali wrote:
> > 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:
> 
>  >>> from Tkinter import *
>  >>> root = Tk()
>  >>> s = 'àéèù: ça marche!'
>  >>> u = unicode(s, 'iso8859-1')
>  >>> Label(root, text=u).pack()
> 
> (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?



More information about the Python-list mailing list