首先, 默认安装的cygwin是不能运行窗口程序的
import * from tkinter Tk() mainloop()
python3 py.py #py.py内容是上段代码
Traceback (most recent call last): File "py.py", line 3, in <module> Tk() File "/usr/lib/python3.4/tkinter/__init__.py", line 1851, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable
export DISPLAY=:0.0 #或者 export DISPLAY=0:0 #抑或 export DISPLAY=localhost:12.0
Traceback (most recent call last): File "py.py", line 3, in <module> Tk() File "/usr/lib/python3.4/tkinter/__init__.py", line 1851, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: couldn‘t connect to display ":0.0"
export DISPLAY=:0.0
startx
$/usr/bin/xterm: Xt error: Can‘t open display: :0.0
Some products that have been reported to cause problems: Aventail Connect Zonealarm PC Firewall from Zonelab Note: These products may not cause problems in all configurations. However, the Cygwin/X project has neither the time, ability, nor resources to help you correctly configure your third-party software.
xorg-server
and xinit
, and run startxwin
.export DISPLAY=:0.0
startxwin & #后面加上&就可以了继续在cygwin里面输入命令了,不出意外的话应该可以了,而且托盘会有xming的图标,可以从那退出
startxwin &> x-server-log &
export DISPLAY=:0.0
export DISPLAY=:0.0 startxwin &> x-server-log &
原文:http://www.cnblogs.com/bovenson/p/5118360.html