I am trying to run a pyqt4 example through Notepad++. 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. Now, when I run the example code I get the following error from npp's console. nppExec command --> 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.
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. Does Cygwin's python installation lack the classic 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
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. Packages dedicated to Windows obviously don't.
Basically you have two choices:
Install X server for Cygwin like this:
xorg-server
package startx
If this causes you problems, try:
xwin -multiwindow
instead of startx
Now an icon should appear in your tray.
xterm
. Congratulations! You just ran an xterm
shell in X environment. See if your application works now.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.