thread problem
This commit is contained in:
parent
9f7ee78992
commit
c4fc345f8d
2 changed files with 15 additions and 5 deletions
|
@ -11,7 +11,7 @@ Created on 2017年12月11日
|
|||
'''
|
||||
import sys
|
||||
|
||||
from PyQt5.QtCore import QTimer, pyqtSignal, Qt
|
||||
from PyQt5.QtCore import pyqtSignal, Qt
|
||||
from PyQt5.QtWidgets import QWidget, QApplication, QVBoxLayout, QTextBrowser, QPushButton,\
|
||||
QMessageBox
|
||||
import keyboard
|
||||
|
|
|
@ -4,10 +4,20 @@ pip install keyboard
|
|||
|
||||
https://github.com/892768447/keyboard
|
||||
|
||||
说明:
|
||||
|
||||
- keyboard模块使用全局低级钩子的方式hook键盘来处理,对系统有一定的影响
|
||||
- 有反映说弹出对话框假死,这里粗略解决下使用信号槽的方式来弹出对话框
|
||||
* keyboard
|
||||
* 该模块使用全局低级钩子的方式hook键盘来处理,对系统有一定的影响
|
||||
* 有反映说弹出对话框假死,这里粗略解决下使用信号槽的方式来弹出对话框
|
||||
* 该模块里使用了每次产生一个子线程来回调函数
|
||||
```
|
||||
def call_later(fn, args=(), delay=0.001):
|
||||
"""
|
||||
Calls the provided function in a new thread after waiting some time.
|
||||
Useful for giving the system some time to process an event, without blocking
|
||||
the current execution flow.
|
||||
"""
|
||||
thread = _Thread(target=lambda: (_time.sleep(delay), fn(*args)))
|
||||
thread.start()
|
||||
```
|
||||
|
||||
# 截图
|
||||
![截图](ScreenShot/1.gif)
|
Loading…
Reference in a new issue