Handling letters with accents

Martyn Quick mrq at for.mat.bham.ac.uk
Fri Feb 7 15:15:23 CET 2003


Hi All,

This is probably standard stuff, and I suspect it has something to do with
unicode, but I don't as yet know enough to deal with it.

If I create a Tkinter entry (with attached textvariable), then someone
using Windows can use various keys (e.g., Ctr+Alt+u) to enter letters with
accents into the entry.  How do I then retrieve the data entered in such a
way that I can deal with it?  In the end, I would like to export it to
HTML, so I will also need to be able to convert this stuff to the HTML
standard ("ú" for the above example), and again I'm not certain how
this is done (though not knowing the answer to the previous question is
clearly an obstacle).

To give a basic example (which illustrates the problem on a Windows98
machine, and probably on later versions of Windows too)...

import Tkinter
root = Tkinter.Tk()
var = Tkinter.StringVar()
Tkinter.Entry(root, textvariable=var).pack()

Typing CTR+ALT+u into the entry and then calling

print var.get()

produces a small amount of garbage that looks nothing like the u with
acute accent that appears in the entry box.

How do I successfully retrieve this data?

Cheers,
Martyn

--------------------------------------------------------
Dr. Martyn Quick  (Research Fellow in Pure Mathematics)
University of Birmingham, Edgbaston, Birmingham, UK.
http://www.mat.bham.ac.uk/M.R.Quick/





More information about the Python-list mailing list