开发者

Hide Python Launcher icon for new QApplication()

开发者 https://www.devze.com 2023-03-21 02:00 出处:网络
I have a Threaded program that runs in the background that creates one QApplication() per thread, and everytime I got a new Python Launcher icon on my dock.开发者_C百科

I have a Threaded program that runs in the background that creates one QApplication() per thread, and everytime I got a new Python Launcher icon on my dock.

开发者_C百科

Is there a way to start a QApplication() without creating a dock icon on OSX?

Thanks!


There are ways to remove/disable the dock icon. See this question: "How to hide the Dock icon"

I use this Python code (after I created the QApplication instance):

def hideMacDockIcon():
    import AppKit
    # https://developer.apple.com/library/mac/#documentation/AppKit/Reference/NSRunningApplication_Class/Reference/Reference.html
    NSApplicationActivationPolicyRegular = 0
    NSApplicationActivationPolicyAccessory = 1
    NSApplicationActivationPolicyProhibited = 2
    AppKit.NSApp.setActivationPolicy_(NSApplicationActivationPolicyProhibited)


The answer is here: Start a GUI process in Mac OS X without dock icon

Put the following lines before instantiating QApplication:

import AppKit
info = AppKit.NSBundle.mainBundle().infoDictionary()
info["LSBackgroundOnly"] = "1"
0

精彩评论

暂无评论...
验证码 换一张
取 消