简体   繁体   English

PyQt5 Python代码无法跨平台工作

[英]PyQt5 Python code not working cross platform

so i wrote a little GUI application in PyQt5 Designer(On my Linux machine) and i converted my GUI.ui to Python code and it runs just fine with the line 所以我在PyQt5 Designer中(在Linux机器上)编写了一个小GUI应用程序,然后将GUI.ui转换为Python代码,并且该代码运行得很好

   $ python guiProto.py

the gui pops up and buttons work ect. gui弹出,按钮起作用。

So Now i load up my windows computer and try to run the same python code using Cygwin64 terminal, and i get the following.. 所以现在我加载我的Windows计算机,并尝试使用Cygwin64终端运行相同的python代码,然后得到以下结果。

    $ python guiProto.py
    QXcbConnection: Could not connect to display

This was not an issue at all running on my Linux machine, i looked at the generated python code and it does not seem to specify operating systems or anything like that.. and i have looked up this "QXcbConnection: Could not connect to display" error and it is just not related to PyQt5 so i was confused 这根本不是我的Linux机器上运行的问题,我查看了生成的python代码,它似乎没有指定操作系统或类似的名称。错误,它只是与PyQt5不相关,所以我很困惑

I made sure i had PyQt5 installed 我确定我已安装PyQt5

 $ pip3 install PyQt5

 Requirement already satisfied: PyQt5 in c:\users\ryan\anaconda3\lib\site-packages (5.11.2)
 Requirement already satisfied: PyQt5_sip<4.20,>=4.19.11 in 
 c:\users\ryan\anaconda3\lib\site-packages (from PyQt5) (4.19.12)

I did design the GUI with Designer on my linux machine and i do not have that on my windows, i did not think that would make a difference since i have the PyQt5 package installed. 我确实在Linux机器上使用Designer设计了GUI,但在Windows上却没有,但我认为这不会有所作为,因为我安装了PyQt5软件包。

Any help would be appreciated for why this would work on my linux computer but not my windows.. 任何帮助将不胜感激,为什么它可以在我的linux计算机而不是Windows上运行。

Linux GUI programs are displayed by X server. Linux GUI程序由X服务器显示。 Seems that your Cygwin installation is missing it. 似乎您的Cygwin安装丢失了它。 Install the packages xorg-server and xinit , and run startxwin . 安装软件包xorg-serverxinit ,然后运行startxwin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM