From 9f7ee78992b5a6be0de0f54cc347864d6e8e9fcb Mon Sep 17 00:00:00 2001 From: Irony <892768447@qq.com> Date: Sun, 22 Apr 2018 09:19:30 +0800 Subject: [PATCH] fix dialog --- 全局热键/HotKey.py | 11 ++++++++++- 全局热键/README.md | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/全局热键/HotKey.py b/全局热键/HotKey.py index f42ae3e..095c87f 100644 --- a/全局热键/HotKey.py +++ b/全局热键/HotKey.py @@ -11,7 +11,9 @@ Created on 2017年12月11日 ''' import sys -from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QTextBrowser, QPushButton +from PyQt5.QtCore import QTimer, pyqtSignal, Qt +from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QTextBrowser, QPushButton,\ + QMessageBox import keyboard @@ -22,9 +24,12 @@ __Version__ = "Version 1.0" class Window(QWidget): + dialogShow = pyqtSignal() + def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) layout = QVBoxLayout(self) + self.dialogShow.connect(self.onShowDialog, type=Qt.QueuedConnection) self.logView = QTextBrowser(self) self.logView.append("点击右上角关闭按钮会隐藏窗口,通过热键Alt+S来显示") self.logView.append("等待热键中") @@ -53,6 +58,10 @@ class Window(QWidget): self.logView.append('按下alt+s') self.show() self.showNormal() + self.dialogShow.emit() + + def onShowDialog(self): + QMessageBox.information(self, '对话框', '按下alt+s键') def onHide(self): """隐藏""" diff --git a/全局热键/README.md b/全局热键/README.md index 67b25c8..759dc50 100644 --- a/全局热键/README.md +++ b/全局热键/README.md @@ -4,5 +4,10 @@ pip install keyboard https://github.com/892768447/keyboard +说明: + + - keyboard模块使用全局低级钩子的方式hook键盘来处理,对系统有一定的影响 + - 有反映说弹出对话框假死,这里粗略解决下使用信号槽的方式来弹出对话框 + # 截图 ![截图](ScreenShot/1.gif) \ No newline at end of file