6

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!

nbarraille
  • 9,926
  • 14
  • 65
  • 92

2 Answers2

7

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"
Community
  • 1
  • 1
Giancarlo Sportelli
  • 1,219
  • 1
  • 17
  • 20
7

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)
Community
  • 1
  • 1
Albert
  • 65,406
  • 61
  • 242
  • 386
  • 1
    If you are not using the Python distribution bundled with Mac OS X, you need to install PyObjC, e.g. with MacPorts for Python3.2 using `sudo port install py32-pyobjc-cocoa`. – Feuermurmel Feb 14 '13 at 10:00
  • Thanks. I missed the `after QApplication` part, which turns out to matter. – rdrey Aug 01 '15 at 18:37