GUI中的希腊字母 - PYTHON

时间:2011-07-07 01:12:22

标签: python tkinter

我不知道如何在GUI中编写希腊字母。我正在研究物理程序,我需要在GUI上显示单位。

我是否必须下载任何额外的库?我必须使用一个模块吗?在GUI中编写字母的最简单方法是什么?

我读了很多关于UTF8的内容,但没有弄清楚如何使用它。

我正在使用Tkinter作为GUI

我正在使用Python 2.6.6

由于

3 个答案:

答案 0 :(得分:6)

Unicode包括希腊字母和几个数学符号的定义。如果您在您的环境中使用任何形式的Unicode,它应该很简单:

>>> from Tkinter import *
>>> root = Tk()
>>> w = Label(root, text=u"Hello, \u03bc-world!")
>>> w.pack()
>>> root.mainloop()

这将打印“Hello,μ-world!”在Tkinter窗口中。

答案 1 :(得分:1)

IDLE使用Tkinter,希腊字母似乎在我身上很好用

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 2.6.5      
>>> print "Ω ω"
Ω ω
>>> 

如果您希望在源代码中使用unicode,则应该包含这样的一行

# -*- coding: utf-8 -*-

在每个文件的顶部

答案 2 :(得分:0)

>>> print( u'\u03a9' )
Ω

适合我。

你有什么具体的问题?