在 PyQt 中显示其他语言字符 [英] Displaying other language characters in PyQt

查看:47
本文介绍了在 PyQt 中显示其他语言字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 PyQt4 中显示其他语言字符?如果有,我应该采取什么方法/方向?提前致谢.

Is there a way to display other language characters in PyQt4? and if there is, what's the approach/direction that I should take? Thanks in advance.

推荐答案

Qt 使用 Unicode,并且应该能够以您有合适字体的任何语言显示 (Unicode) 文本.例如,Roberto Alesina 在 PyQt Wiki 上的简单Hello World"程序——我将其转录为可读性(并且为了简洁起见,没有注释)因为它在 wiki 中非常不可读——应该让你使用任何这样的 Unicode 文本作为按钮的文本(所以我冒昧地翻译它,所以它使用一个带重音的字母;-)...:

Qt uses Unicode and should be able to display (Unicode) text in any language you have a suitable font for. For example, Roberto Alesina's simple "Hello World" program on the PyQt Wiki -- which I transcribe for readability (and w/o the comments for brevity) since it's pretty unreadable in the wiki -- should let you use as the button's text any such Unicode text (so I've taken the liberty of translating it so it uses an accented letter;-)...:

# -*- coding: utf-8 -*-
# (or w/ever other coding you use for unicode literals;-)
import qt, sys
a=qt.QApplication(sys.argv)
w=qt.QPushButton(u"Olá Mundo", None)
w.show()
a.exec_loop()

这篇关于在 PyQt 中显示其他语言字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆