How to hide application icon from Mac OS X dock

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 10:01:11

问题


I have a wxpython script, which creates a wx.App and a frame, hides it and does some processing using hidden frame. I do not want this script's icon to appear in Mac dock but it comes. So how can i hide it, I did not find anything in wxPython so it there some carbon API which I can call?

Simplest python script makes icon to appear

>>> import wx
>>> app = wx.App()

回答1:


I was not able to find a way to hide app icon programmatically, only way seems to be to set LSUIElement=1 in Info.plist, so the apps which need to switch on and off icon depending on user option may have to have two app which share all the code using symbolic links except the info.plist files which will be different for different mode app.

Anyway this explains it better

http://codesorcery.net/2008/02/06/feature-requests-versus-the-right-way-to-do-it




回答2:


Using this AppKit code before load your app:

from AppKit import NSBundle
bundle = NSBundle.mainBundle()
info = bundle.localizedInfoDictionary() or bundle.infoDictionary()
info['LSUIElement'] = '1'


来源:https://stackoverflow.com/questions/4345102/how-to-hide-application-icon-from-mac-os-x-dock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!