Displaying other language characters in PyQt

自古美人都是妖i 提交于 2021-02-04 16:47:19

问题


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.


回答1:


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()


来源:https://stackoverflow.com/questions/3183044/displaying-other-language-characters-in-pyqt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!