我试着做:
from graphics import *
win = GraphWin()
pt = Point(100, 50)
pt.draw(win)
cir = Circle(pt, 25)
cir.draw(win)
cir.setOutline('red')
cir.setFill('blue')
然而,无论我从网上尝试在cygwin上安装什么,它都会给出:
Traceback (most recent call last):
File "observe.py", line 2, in <module>
from graphics import *
File "/home/user/graphics.py", line 164, in <module>
_root = tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1814, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
当我转到Ubuntu或Mac时,它似乎有不同的行为。
您确定您的X服务器正在运行吗?
这应该是
[…]通过使用";XWin服务器";快捷方式下的";Cygwin-X";在…上开始菜单
根据http://x.cygwin.com/docs/ug/using.html