fix dialog
This commit is contained in:
parent
f45d8164af
commit
9f7ee78992
2 changed files with 15 additions and 1 deletions
|
@ -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):
|
||||
"""隐藏"""
|
||||
|
|
|
@ -4,5 +4,10 @@ pip install keyboard
|
|||
|
||||
https://github.com/892768447/keyboard
|
||||
|
||||
说明:
|
||||
|
||||
- keyboard模块使用全局低级钩子的方式hook键盘来处理,对系统有一定的影响
|
||||
- 有反映说弹出对话框假死,这里粗略解决下使用信号槽的方式来弹出对话框
|
||||
|
||||
# 截图
|
||||
![截图](ScreenShot/1.gif)
|
Loading…
Reference in a new issue