pythonmacospython-3.xtkinter

How to run a Python 3 tkinter app without opening any Terminal windows in Mac OS X?


I developed a GUI app in Python 3. I want to be able to launch it by clicking on the script itself or in a custom-made launching script. I have changed permissions and it's now opening with "Python Launcher" on double-click. But everytime I run my app, I get a lot of windows:

What is the easiest way to get only the GUI on screen, without any Terminal windows?


Solution

  • Following the suggestion bu linusg, I discovered that I can accomplish this by creating an AppleScript application with the following code (adjusting the paths of python3 and of the Python application as needed):

    do shell script "export LC_ALL=en_US.UTF-8; export LANG=en_US.UTF-8; /usr/local/bin/python3 '/Users/USER/FOLDER/SCRIPT.py' &> /dev/null &"
    

    It launches the Python application without Terminal Windows. The AppleScript application can then be personalised with a custom icon as usual, and can be placed in the Dock. When clicked, it will launch the Python intepreter, that still shows up in Dock, but with no visible windows.

    I think this may be useful to other users.