无法在cygwin中运行python图形

时间:2016-04-10 20:42:41

标签: python graphics cygwin x11 xserver

我试着这样做:

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时,似乎有不同的行为。

1 个答案:

答案 0 :(得分:0)

您确定您的X服务器正在运行吗?

应该这样做

  

[...]使用“Cygwin-X”下的“XWin Server”快捷方式   开始菜单

......根据http://x.cygwin.com/docs/ug/using.html