Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Python Launcher icon for new QApplication()

Tags:

python

macos

pyqt

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.

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

Thanks!

like image 855
nbarraille Avatar asked Sep 02 '26 09:09

nbarraille


1 Answers

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)
like image 186
Albert Avatar answered Sep 04 '26 00:09

Albert