在使用Anki制作卡片的时候为了醒目起见,需要修改文字颜色,最好是多种颜色交替,所以找了个插件Quick Colour Changing. 按照文档修改了配置,快捷键设置为了Ctrl+1/2/3/4. 结果发现完全没有反应。

看了下代码,只有十来行是很好理解的。代码逻辑正常,但就是没办法使用。想来一定是快捷键映射的问题。因为Anki基于PyQt构建,最后翻了下PyQt的文档. 有以下这句高亮标识

On macOS, references to “Ctrl”, CTRL , Key_Control and ControlModifier correspond to the Command keys on the Macintosh keyboard, and references to “Meta”, META , Key_Meta and MetaModifier correspond to the Control keys. Developers on macOS can use the same shortcut descriptions across all platforms, and their applications will automatically work as expected on macOS.

还是挺奇葩的,你写Ctrl会映射到Command, 写Command无效,写Meta映射到Command…..

所以在Mac上使用这个插件配置的时候需要特别小心…… 毕竟看起来非常违反直觉

参考

https://doc.qt.io/qtforpython-5/PySide2/QtGui/QKeySequence.html#more

PyQt QShortcut

Quick Colour Changing

PyQt print event

评论和共享

  • 第 1 页 共 1 页

ficapy

author.bio


author.job


深圳