[英]unable to run PyQt4 example
I am trying to run a pyqt4 example through Notepad++. 我正在尝试通过记事本++运行pyqt4示例。 I asked this question earlier ( Nothing happens when running PyQt4 example code ), and ended up uninstalling Enthought Canopy and all remnants of python and installing cygwin. 我早些时候问了这个问题( 运行PyQt4示例代码时什么也没有发生 ),最终卸载了Enthought Canopy和所有python残余并安装了cygwin。 Now, when I run the example code I get the following error from npp's console. 现在,当我运行示例代码时,我从npp的控制台收到以下错误。 nppExec command --> C:\\cygwin\\bin\\python2.7.exe -i "$(FULL_CURRENT_PATH)"
. nppExec命令-> C:\\cygwin\\bin\\python2.7.exe -i "$(FULL_CURRENT_PATH)"
。 The example code is shown all the way at the bottom. 示例代码始终显示在底部。
The closest I can get is to start cygwin x (type startx from the bash shell) where I can get the example window to come up, although I am unable to exit out of the window. 我能得到的最接近的是启动cygwin x(从bash shell输入startx),尽管我无法退出该窗口,但可以在该窗口中打开示例窗口。
I feel like I am in over my head here, I just want to create some simple GUI's and I am struggling just to get an example to work. 我感觉自己在这里,我只是想创建一些简单的GUI,而我正努力使示例工作。 Does Cygwin's python installation lack the classic IDLE? Cygwin的python安装缺少经典的IDLE吗?
C:\cygwin\bin\python2.7.exe -i "C:\Users\Brian\Dropbox\Python\PYqt_practice.py"
Process started >>>
cygwin warning:
MS-DOS style path detected: C:\Users\Brian\Dropbox\Python\PYqt_practice.py
Preferred POSIX equivalent is: /cygdrive/c/Users/Brian/Dropbox/Python/PYqt_practice.py
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
C:\Users\Brian\Dropbox\Python\PYqt_practice.py: cannot connect to X server
<<< Process finished. (Exit code 1)
================ READY ================
PyQt4 example code PyQt4示例代码
import sys
from PyQt4 import QtGui
def main():
app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
PyQT4 and PyQT5 installed with Cygwin emulate directly what their equivalent Linux packages do, meaning they do expect you to run an X server. 与Cygwin一起安装的PyQT4和PyQT5直接模拟它们等效的Linux软件包的作用,这意味着它们确实希望您运行X服务器。 Packages dedicated to Windows obviously don't. Windows专用软件包显然没有。
Basically you have two choices: 基本上,您有两种选择:
Install X server for Cygwin like this: 像这样为Cygwin安装X服务器:
xorg-server
package 获取xorg-server
软件包 startx
运行startx
If this causes you problems, try: 如果这导致您遇到问题,请尝试:
xwin -multiwindow
instead of startx
运行xwin -multiwindow
而不是startx
Now an icon should appear in your tray. 现在,图标应该出现在您的任务栏中。
xterm
. 单击xterm
。 Congratulations! 恭喜你! You just ran an xterm
shell in X environment. 您只需在X环境中运行xterm
shell。 See if your application works now. 查看您的应用程序现在是否可以运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.