[英]wxPython (Phoenix) retina status icon
我正在尝试为Mac OS X(El Capitan)构建wxPython应用程序,并在具有视网膜显示功能的MBP上工作。
我只是复制了Google云端硬盘应用的状态图标-16x16和32x32(2x)并使其模糊。
我还尝试了这张票中的代码,但没有帮助。
我的代码如下所示:
icon = wx.Icon('icon@2x.png', wx.BITMAP_TYPE_ANY)
结果(最左边的图标是我的):
wxPython版本:3.0.3.dev1836 + f764b32 osx-cocoa(phoenix)
PS。 我知道Google云端硬盘也基于wxPython构建。 但状态栏中的视网膜图像质量良好。 他们是如何做到的?
一种方法是在设置图标之前检查刻度:
import sys; print sys.version
import wx; print wx.version()
if 'phoenix' not in wx.PlatformInfo: exit()
class CreateTestFrame(wx.Frame):
def __init__(self):
return wx.Frame.__init__(self, None, -1, "test frame")
wxSandbox = wx.App()
testFrame = CreateTestFrame()
print "Scale factor: ", testFrame.GetContentScaleFactor()
if testFrame.GetContentScaleFactor() < 2.0:
print "Not 'Retina' scaling"
icon = wx.Icon('./icons/mac-normal.png', wx.BITMAP_TYPE_ANY)
print "pixel height", icon.GetHeight()
else:
print "'Retina' scaling"
icon = wx.Icon('./icons/mac-normal@2x.png', wx.BITMAP_TYPE_ANY)
print "pixel height", icon.GetHeight()
testFrame.SetIcon(icon)
testFrame.Show()
wxSandbox.MainLoop()
exit()
我的显示屏上的比例显示为“ 2.0”,并且它正确选择了32x32图标。
2.7.11(默认,2015年12月5日,14:44:53)
[GCC 4.2.1兼容的Apple LLVM 7.0.0(clang-700.1.76)]
'3.0.3(thorr18)-f764b32 osx-可可粉(凤凰)'
比例系数:2.0
视网膜缩放
像素高度32流程结束,退出代码为0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.