我试着这样做:
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')
然而,无论我在网上试过什么安装,我都试过:
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时,似乎有不同的行为。
答案 0 :(得分:0)
您确定您的X服务器正在运行吗?
应该这样做
[...]使用“Cygwin-X”下的“XWin Server”快捷方式 开始菜单