简体   繁体   English

wxPython(Phoenix)视网膜状态图标

[英]wxPython (Phoenix) retina status icon

I am trying to built wxPython app for Mac OS X (El Capitan) and working on MBP with retina display. 我正在尝试为Mac OS X(El Capitan)构建wxPython应用程序,并在具有视网膜显示功能的MBP上工作。

I just copied Google Drive app status icons - 16x16 and 32x32 (2x) and get it blurry. 我只是复制了Google云端硬盘应用的状态图标-16x16和32x32(2x)并使其模糊。

I also tried code from this ticket and it doesn't help. 我还尝试了这张票中的代码,但没有帮助。

My code looks like this: 我的代码如下所示:

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

And result (most left icon is mine): 结果(最左边的图标是我的):

在此处输入图片说明

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

PS. PS。 I know that Google Drive built on wxPython too. 我知道Google云端硬盘也基于wxPython构建。 but it have good retina images in status bar. 但状态栏中的视网膜图像质量良好。 How they do it? 他们是如何做到的?

One way is to check the scale before setting icon: 一种方法是在设置图标之前检查刻度:

    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()

The scale on my display is showing as '2.0' and it correctly selects the 32x32 icon. 我的显示屏上的比例显示为“ 2.0”,并且它正确选择了32x32图标。

2.7.11 (default, Dec 5 2015, 14:44:53) 2.7.11(默认,2015年12月5日,14:44:53)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] [GCC 4.2.1兼容的Apple LLVM 7.0.0(clang-700.1.76)]
'3.0.3(thorr18)-f764b32 osx-cocoa (phoenix)' '3.0.3(thorr18)-f764b32 osx-可可粉(凤凰)'
Scale factor: 2.0 比例系数:2.0
'Retina' scaling 视网膜缩放
pixel height 32 像素高度32

Process finished with exit code 0 流程结束,退出代码为0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM