开发者

How do you display greek characters on a PyQt4 GUI?

I am开发者_Go百科 a bit of a noob, so forgive me if this is a simple question.

I am writing a program to perform scientific simulations, some of the parameters for which are measured in micrometres. The suffix for such parameters is µm where the greek symbol mu preceeds the m for metre.

Ideally i would like to set the suffix for my spin boxes to be µm, but i get the following error: "SyntaxError: Non-ASCII character"

I am comfortable setting the suffix for spin boxes but have no idea about character encoding. I am using Python 2.6 and PyQt4 on windows 7, and this is an example of how i have tried to do this:

spin1 = QtGui.QDoubleSpinBox()
spin1.setSuffix("µm")

This has been really irritating me and i can't get my head around any of the solutions i have found online, so any help would be greatly appreciated.


Using unicode object instead of simple string:

# -*- coding: utf8 -*-

# Your code ...

spin1 = QtGui.QDoubleSpinBox()
spin1.setSuffix(u"µm")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜