簡體   English   中英

wxPython(Phoenix)視網膜狀態圖標

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM