cygwin 运行窗口程序
2016-01-10 14:00
417 查看
首先,默认安装的cygwin是不能运行窗口程序的
比如,一段python窗口程序:
如果使用命令行:
会提示如下错误:
网上搜索,很多人说通过命令行:
然而,这个错误确实是变了,变成了这样:
然后百度cygwintkinterdisplay,出来的结果我只能用呵呵表示,最后还是用360搜索结合bing,慢慢理清的头绪
发现,如果想要运行窗口程序,需要安装xserver.
可以选择xmingxserver,也就是cygwin/x
最新的cygwin/x是集成在cygwin安装里的,在安装的时候选择安装程序的时候,添加xinit
我把xorg也选上了
完成安装后,我是用命令:
结果异常退出,提示:
很奇怪,后来从http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-cannot-open-display看到这么一句:
吓得我赶紧把360那俩货关了,结果还是不行,看来是冤枉他们了,让后又360so,找到这么一句:
Cygwindoesn'tautomaticallystartanXserver.Youneedtoinstallthepackagesrun
阿西吧,原来是用命令:
效果是这样的:
有x图标的那个就是xserver
这是py.py运行的结果
就可以把标准输出和标准错误输出重定向的文件s-server-log中,在cygwin控制台中,就看不到xserver的输出信息
如果每次启动都需要启动xserver
可以在~/.bashrc中在最后添加两行代码:
比如,一段python窗口程序:
import*fromtkinter Tk() mainloop()
如果使用命令行:
python3py.py#py.py内容是上段代码
会提示如下错误:
Traceback(mostrecentcalllast): File"py.py",line3,in<module> Tk() File"/usr/lib/python3.4/tkinter/__init__.py",line1851,in__init__ self.tk=_tkinter.create(screenName,baseName,className,interactive,wantobjects,useTk,sync,use) _tkinter.TclError:nodisplaynameandno$DISPLAYenvironmentvariable
网上搜索,很多人说通过命令行:
exportDISPLAY=:0.0 #或者 exportDISPLAY=0:0 #抑或 exportDISPLAY=localhost:12.0
然而,这个错误确实是变了,变成了这样:
Traceback(mostrecentcalllast): File"py.py",line3,in<module> Tk() File"/usr/lib/python3.4/tkinter/__init__.py",line1851,in__init__ self.tk=_tkinter.create(screenName,baseName,className,interactive,wantobjects,useTk,sync,use) _tkinter.TclError:couldn'tconnecttodisplay":0.0"
然后百度cygwintkinterdisplay,出来的结果我只能用呵呵表示,最后还是用360搜索结合bing,慢慢理清的头绪
发现,如果想要运行窗口程序,需要安装xserver.
可以选择xmingxserver,也就是cygwin/x
最新的cygwin/x是集成在cygwin安装里的,在安装的时候选择安装程序的时候,添加xinit
我把xorg也选上了
完成安装后,我是用命令:
exportDISPLAY=:0.0
startx
结果异常退出,提示:
$/usr/bin/xterm:Xterror:Can'topendisplay::0.0
很奇怪,后来从
Someproductsthathavebeenreportedtocauseproblems: AventailConnect ZonealarmPCFirewallfromZonelab Note:Theseproductsmaynotcauseproblemsinallconfigurations.However,theCygwin/Xprojecthasneitherthetime,ability,norresourcestohelpyoucorrectlyconfigureyourthird-partysoftware.
吓得我赶紧把360那俩货关了,结果还是不行,看来是冤枉他们了,让后又360so,找到这么一句:
Cygwindoesn'tautomaticallystartanXserver.Youneedto
xorg-serverand
xinit,and
startxwin.
阿西吧,原来是用命令:
exportDISPLAY=:0.0
startxwin后面加上&就可以了继续在cygwin里面输入命令了,不出意外的话应该可以了,而且托盘会有xming的图标,可以从那退出
效果是这样的:
有x图标的那个就是xserver
这是py.py运行的结果
startxwin&>x-server-log&
exportDISPLAY=:0.0
就可以把标准输出和标准错误输出重定向的文件s-server-log中,在cygwin控制台中,就看不到xserver的输出信息
如果每次启动都需要启动xserver
可以在~/.bashrc中在最后添加两行代码:
exportDISPLAY=:0.0 startxwin&>x-server-log&
相关文章推荐
- VS201x+Qt5开发,中文乱码解决
- openlayers中获得geojson格式数据
- 华为机试——字符统计
- 更新Xcode出现"使用libswiftCore.dylib插件时Xcode意外退出"解决方案
- 蓝桥杯 历届试题 分糖果
- 机器学习之距离和相似性度量方法
- 《笨办法学Python》 第10课手记
- 华为机试——自守数
- 1、JAVA的简单介绍、入门,开发环境搭建、开发Java程序
- CheckBox 控件的使用 day2.1
- [示例]创建Student类,输入学生信息并存入字典,将3个存有学生信息的字典存入数组,并计算
- Objective-C 9 常用结构体
- 债券投资基本知识
- 学习笔记——支持向量机svm(3)kernel trick(核函数)
- mysql 导入txt中记录
- 华为机试——连续最长数字串
- Ubuntu 14.04下搭建Python3.4 + PyQt5.3.2 + Eric6.0开发平台
- android4.4组件分析--service组件
- 折腾域名的dns
- 数据结构和算法笔记