We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to shutdown when Ctrl+C is pressed.
from PyQt5.QtWidgets import QMainWindow, QSplitter, QPushButton from PyQt5.QtCore import Qt from qasync import QEventLoop, QApplication, asyncClose, asyncSlot import sys import asyncio class MainWindow(QMainWindow): def __init__(self, app): self.app = app super().__init__() self.setWindowTitle("MainWindow") self.setGeometry(100, 100, 800, 600) splitter = QSplitter(Qt.Horizontal) self.setCentralWidget(splitter) send_button = QPushButton('button') splitter.addWidget(send_button) @asyncClose async def closeEvent(self, event): pass @asyncSlot() async def onMyEvent(self): pass def main(): app = QApplication(sys.argv) event_loop = QEventLoop(app) asyncio.set_event_loop(event_loop) app_close_event = asyncio.Event() app.aboutToQuit.connect(app_close_event.set) main_window = MainWindow(app) main_window.show() with event_loop: event_loop.run_until_complete(app_close_event.wait()) main()
python test.py Press Ctrl+C and close button.
python test.py
^CTraceback (most recent call last): File "/opt/miniconda3/envs/mar/lib/python3.11/site-packages/qasync/__init__.py", line 766, in wrapper @functools.wraps(fn) KeyboardInterrupt [1] 3160831 IOT instruction (core dumped) python src/test.py
pyqt5 5.14.2 qasync 0.27.1
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I want to shutdown when Ctrl+C is pressed.
python test.py
Press Ctrl+C and close button.
pyqt5 5.14.2
qasync 0.27.1
The text was updated successfully, but these errors were encountered: