【问题标题】:wxPython (Phoenix) retina status iconwxPython (Phoenix) 视网膜状态图标
【发布时间】:2016-03-26 06:52:28
【问题描述】:

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

我刚刚复制了 Google Drive 应用程序状态图标 - 16x16 和 32x32 (2x) 并且变得模糊。

我也尝试了this ticket 的代码,但没有帮助。

我的代码如下所示:

icon = wx.Icon('icon@2x.png', wx.BITMAP_TYPE_ANY)

结果(最左边的图标是我的):

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

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

【问题讨论】:

  • 嗯。看起来 wx 出于某种原因将我的笔记本电脑检测为非视网膜(wxOSXGetMainScreenContentScaleFactor 为 1.0)。

标签: python macos wxpython wxwidgets


【解决方案1】:

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

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

进程以退出代码 0 结束

【讨论】:

  • 看我自己的评论是行不通的(在视网膜上检测到比例为 1.0)。
  • 检测为1.0后,选择16x16图标,得到模糊的结果?
  • 两个 16x16/32x32 图标看起来都很模糊(在没有 if 条件的情况下尝试过)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多