wxPython(凤凰城)视网膜状态图标

时间:2015-12-19 19:44:31

标签: python macos wxpython wxwidgets

我正在尝试为Mac OS X(El Capitan)构建wxPython应用程序,并使用视网膜显示器处理MBP。

我刚刚复制了Google云端硬盘应用状态图标 - 16x16和32x32(2x)并且模糊不清。

我也尝试过来自this ticket的代码,但它没有帮助。

我的代码如下所示:

implicit val personCodec = RowCodec.caseCodec2(Person.apply, Person.unapply)(0, 1)

结果(大多数左图标是我的):

enter image description here

wxPython版本:3.0.3.dev1836 + f764b32 osx-cocoa(phoenix)

PS。我知道Google Drive也建立在wxPython之上。但它在状态栏中有很好的视网膜图像。他们是怎么做到的?

1 个答案:

答案 0 :(得分:0)

一种方法是在设置图标之前检查比例:

    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-cocoa(凤凰)'
  比例因子:2.0
  '视网膜'缩放
  像素高度32

     

处理完成,退出代码为0

相关问题