[PyKDE] Problem with German characters
jblazi
jblazi at gmx.de
Tue Oct 15 22:51:01 BST 2002
On Tuesday 15 October 2002 21:58, Jim Bublitz wrote:
> I'm not at all clear on what your code is trying to do, but if
> ".text()" is Qt code, it almost invariably returns a QString,
> therefore you should need latin1(), utf8() or something similar from
> QString to return an actual character string before using it with
> any Python functions.
My application is very simple. There is a QTextEdit widget where the user can
enter some text. For example he may enter
a = point(1,1)
b = point(1,8=
draw(a,b)
and the, after he clicks on a toolbotton, the points a and b are drawn in
another widget.
So when the user clicks on that tool button, I read the text of the QTextEdit
and execute it. As draw is one of the procedures in my Python program, it is
executed and the drawing is done.
Of course I know that I have to convert QStrings to Python strings. If I do
not, I get error messages that tell me that I use an instance where an string
is expected.
The problem is, that do not know how to convert: I tried str(...) and
.latin1() but none of them works when the text of the QTextEdit contains
German characters. The problem is that I have two commands that insert a
caption and a legend, respectively, and these commands might contain such
characters.
(The available comands reflect basically what you can do with a ruler and a
compass and the program is a toy for kids who can learn how ruler and compass
constructions work. You can easily construct the circle of nine points in a
triangle for example. If you do it by a real ruler and a real compass, it is
almost impossible to get it right.)
--
Janos Blazi
More information about the PyQt
mailing list