python - 从 .app 运行时窗口变得模糊/像素化
问题描述
我制作了一个小 Python 脚本,它在 QtWidget 上运行时钟,一切正常。
我想用它制作一个可执行文件,因此我使用了 pyinstaller 并且从代码的角度来看一切正常。
但是,当我创建一个 .app (macOS)(使用 -w 选项)并使用此应用程序运行脚本时,窗口及其内容的质量会变得更差,就像模糊/像素化一样。奇怪的是,如果我从 .app/Contents/MacOS/ 中提取脚本并从应用程序外部的文件夹中运行它,质量就会再次正常。
看截图:
正常质量
质量差
有谁知道为什么会这样?和/或如何解决?
解决方案
在应用程序的 info.plist 文件中将“NSHighResolutionCapable”设置为“True”应该可以解决问题。
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>port_poirot</string>
<key>CFBundleExecutable</key>
<string>MacOS/port_poirot</string>
<key>CFBundleIconFile</key>
<string>detective.icns</string>
<key>CFBundleIdentifier</key>
<string>port_poirot</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>port_poirot</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.0</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
</dict>
</plist>
更改 pyinstaller 的规范文件使其更容易一些。请参阅https://pyinstaller.readthedocs.io/en/stable/spec-files.html#spec-file-options-for-a-mac-os-x-bundle
推荐阅读
- javascript - 它没有注册我将鼠标悬停在一个元素上
- javascript - 对象分配嵌套属性 Javascript
- excel - 模块中的 VBA 代码和分配给按钮或文本框的宏给出不同的结果
- c# - 为什么当我从容器中检索对象时会修改它
- go - 如何从 redis Do() 结果中提取数据
- c# - Token Cache with Timer-Triggered Azure Functions
- mongodb - MongoDB 错误:“无法打开新游标,因为已经打开了太多游标”
- c++ - 从 .so/.o 文件中获取 c/cpp 中的静态库列表
- java - Stream.map 和 Collectors.mapping 之间的性能差异
- scala - 是否有任何可变集合的运算符方法可以将结果写回可变运算符调用程序或参数?