小编one*_*ion的帖子

TIS/TSM非主线程错误; 热键触发的pygame脚本(臀部,pygame,键盘)

我正在编写一个python应用程序,其主要目的是运行一个迷你游戏(使用'pygame'库),每当我使用一个热键(目前使用'键盘'库).我希望这个热键被普遍认可,所以我将整个东西打包为状态栏应用程序(使用'rumps'库).

到目前为止,我可以启动整个事情,从状态栏下拉列表选择播放,它的工作原理!大.

但是,如果我尝试使用绑定的热键,运行Play触发器的相同功能,我得到:

python[58226:599749] pid(58226)/euid(0) is calling TIS/TSM in non-main thread
environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
Run Code Online (Sandbox Code Playgroud)

这显示了四次,并且是后续的

python[58226:599749] WARNING: nextEventMatchingMask should only be
called from the Main Thread! This will throw an exception in the future.
Run Code Online (Sandbox Code Playgroud)

为了检查它本身不是热键,我做了一个测试:如果我将热键连接到一个更简单的功能,比如设置一个警报,它工作正常.它仍然抱怨,并给我错误:

python[60308:620099] -[NSAlert runModal] may only be invoked from the main thread. Behavior on other threads is undefined. (
0   AppKit                              0x00007fff2b7f563f -[NSAlert runModal] + 178
1   _objc.cpython-36m-darwin.so         0x000000010c1358c7 ffi_call_unix64 + 79
2   ??? …
Run Code Online (Sandbox Code Playgroud)

python macos keyboard-shortcuts hotkeys keyboard-maestro

6
推荐指数
1
解决办法
1531
查看次数