2015-12-19 58 views
1

我想为Mac OS X(El Capitan)构建wxPython应用程序并使用视网膜显示器工作MBP。wxPython(凤凰)视网膜状态图标

我刚刚复制Google Drive应用状态图标 - 16x16和32x32(2x),并得到它模糊。

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

我的代码如下所示:

icon = wx.Icon('[email protected]', wx.BITMAP_TYPE_ANY) 

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

enter image description here

wxPython的版本:3.0.3.dev1836 + f764b32 OSX可可(凤凰)

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

+0

嗯结束。它看起来像wx检测我的笔记本电脑为非视网膜(wxOSXGetMainScreenContentScaleFactor为1.0)出于某种原因。 – ssbb

回答

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/[email protected]', wx.BITMAP_TYPE_ANY) 
     print "pixel height", icon.GetHeight() 
    testFrame.SetIcon(icon) 
    testFrame.Show() 
    wxSandbox.MainLoop() 
    exit() 

我的显示器上的刻度示出了作为“2.0”和它正确地选择32×32的图标。

2.7.11(默认情况下,2015年12月5日,14时44分53秒)
[4.2.1 GCC兼容苹果LLVM 7.0.0(铛-700.1.76)]
“3.0.3( thorr18)-f764b32 OSX可可(凤)”
比例系数:2.0
'视网膜' 缩放
像素高度32个

过程,退出代码0

+0

看不到我自己的评论(在视网膜上检测到的比例为1.0)。 – ssbb

+0

当它检测为1.0,并选择16x16图标后,你会得到模糊的结果? – thorr18

+0

这两个16x16/32x32图标看起来很模糊(如果条件不合适,尝试)。 – ssbb