I don't know how to write Greek letters in a GUI. I am working on a Physics program and I need to show units on the GUI.
Do I have to download any extra libraries? Is there a module I have to use? What is the easiest way开发者_Python百科 to write the letters in the GUI?
I read a lot about UTF8 but didn't figure out how to use it.
I am using Tkinter for the GUI
I am using Python 2.6.6
Thanks
Unicode includes definitions for both the Greek alphabet and several mathematical symbols. If you are using any form of Unicode in your environment, it should be simple:
>>> from Tkinter import *
>>> root = Tk()
>>> w = Label(root, text=u"Hello, \u03bc-world!")
>>> w.pack()
>>> root.mainloop()
This will print "Hello, μ-world!" in a Tkinter window.
IDLE uses Tkinter, Greek letters seem to work fine in there for me
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 "Ω ω"
Ω ω
>>>
If you wish to use unicode literally in your source, you should include a line like this
# -*- coding: utf-8 -*-
At the top of each file
>>> print( u'\u03a9' )
Ω
Works for me.
What specific problem are you having?
精彩评论