Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide terminal from dock for an executable created using PyInstaller

I'm using PyInstaller (v2.1) to bundle a Python app for different platforms. I'm using an external tool for my GUI which invokes the PyInstaller bundled executable that will act as a backend server.

I'm having problems with bundling on the Mac(OS X 10.10) though. When my PyInstaller bundled Unix executable (which is meant to run as a background process) is invoked from the GUI tool, it successfully starts up w/o a window, but unfortunately, along with a terminal icon in the dock.

I've supplied the --no-console option, with debug=False while building the executable, but to no effect. This seemed to work perfectly on Windows.

Should I be looking at some PyInstaller option to prevent the executable icon from popping up on the Dock? Or should I be looking at some OS X options for the same?

To summarise: I wish to prevent the background process from appearing on the dock(on OS X) when invoked from an external application.

An alternate question could also be: What are the Pyinstaller directives to create a purely background application?

Note: I've also tried bundling my python app as a .app, and tried meddling around with the *.plist file, but that didn't help either(apart from the fact that it doesn't seem right because it's meant to run only as a background process)

Here's how the plist file would look:

...
<plist version="1.0">
<dict>
    ...
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>LSBackgroundOnly</key>
    <string>1</string>
    <key>LSUIElement</key>
    <true/>
</dict>
</plist>
like image 281
farthVader Avatar asked Jun 12 '26 11:06

farthVader


1 Answers

*I've also tried bundling my python app as a .app, and tried meddling around with the .plist file

It would help if you state what you actually did here. Usually the key LSUIElement when set to true should do what you want. As the docs state: -

Specifies whether the app is an agent app, that is, an app that should not appear in the Dock or Force Quit window. See LSUIElement for details.

like image 126
TheDarkKnight Avatar answered Jun 15 '26 01:06

TheDarkKnight



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!