Python 如何使用connexion模块运行PyQt应用程序?
我想在Qt应用程序中运行connexion服务器,但我不知道如何操作 我试过下面这样的方法,但执行被卡在“连接循环”中,“关闭服务器”按钮不会在控制台中显示unit I ctrl-c连接服务器…:Python 如何使用connexion模块运行PyQt应用程序?,python,pyqt,pyqt5,connexion,Python,Pyqt,Pyqt5,Connexion,我想在Qt应用程序中运行connexion服务器,但我不知道如何操作 我试过下面这样的方法,但执行被卡在“连接循环”中,“关闭服务器”按钮不会在控制台中显示unit I ctrl-c连接服务器…: import sys, os import connexion from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QApplication, QPushButton connex_app = connexion.App("Hello W
import sys, os
import connexion
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QPushButton
connex_app = connexion.App("Hello World")
class OpennoteserverDlg(QPushButton):
def __init__(self, parent=None):
super().__init__(
"&Close Server", parent)
self.clicked.connect(self.close)
self.setWindowTitle("Opennote-server")
app = QApplication(sys.argv)
form = OpennoteserverDlg()
form.show()
app.connex_app = connex_app
app.connex_app.run()
app.exec_()
run()
方法正在阻塞,因此它将不允许执行GUI事件循环,从而导致多个GUI任务无法正常工作。解决方案是在另一个线程中运行服务器
导入信号
导入系统
导入线程
导入连接
从PyQt5.qtwidts导入QApplication,QPushButton
类OpennoteserverDlg(QPushButton):
def uuu init uuu(self,parent=None):
超级()
self.clicked.connect(self.close)
self.setWindowTitle(“Opennote服务器”)
def run_服务器():
connex_app=connexion.app(“你好世界”)
connex_应用程序运行()
如果名称=“\uuuuu main\uuuuuuuu”:
signal.signal(signal.SIGINT,signal.SIG_-DFL)
app=QApplication(sys.argv)
form=OpennoteserverDlg()
表格.show()
threading.Thread(target=run\u server,daemon=True).start()
sys.exit(app.exec_())
运行()方法被阻塞,因此它不允许执行GUI事件循环,导致多个GUI任务无法正常工作。解决方案是在另一个线程中运行服务器
导入信号
导入系统
导入线程
导入连接
从PyQt5.qtwidts导入QApplication,QPushButton
类OpennoteserverDlg(QPushButton):
def uuu init uuu(self,parent=None):
超级()
self.clicked.connect(self.close)
self.setWindowTitle(“Opennote服务器”)
def run_服务器():
connex_app=connexion.app(“你好世界”)
connex_应用程序运行()
如果名称=“\uuuuu main\uuuuuuuu”:
signal.signal(signal.SIGINT,signal.SIG_-DFL)
app=QApplication(sys.argv)
form=OpennoteserverDlg()
表格.show()
threading.Thread(target=run\u server,daemon=True).start()
sys.exit(app.exec_())