2

When you create an tkinter (or any graphical interface) app, the Python Launcher shows up in your dock (bottom right hand corner, next to the Trash Can). Even if you change the name of the program in the menu (top bar), it still says "Python". I would like to change the name.

Full

Let's say you have this:

from tkinter import * import sys from Foundation import NSBundle #create window root = Tk() root.title("Caskt Evlofrow") #this makes the name in the MENU "Caskt Evlofrow" if sys.platform == "darwin": bundle = NSBundle.mainBundle() if bundle: info = bundle.localizedInfoDictionary() or bundle.infoDictionary() if info and info['CFBundleName'] == 'Python': info['CFBundleName'] = "Caskt Evlofrow" root.mainloop() 

Credit to this question to change the menu name. However, even though it changes the MENU name, it doesn't change the DOCK name (the name that the Python Launcher rocket says). How can I change the DOCK name?

What I've Done So far I've tried looking it up on google. I tried looking at linked questions from this question. But I still can't find it. I might be using the wrong keywords, so any help is extremely appreciated!

Common Mistaken Thoughts Some people are saying that I should make it into an "executable." However, the python launcher still says "Python," so it doesn't really help my problem. Also, CFBundleDisplayName doesn't exist in my version of macOS (Mojave).

This is an image of what I want:

What is regularly shown Original What I want it to show What I want

7
  • How are you running your file? If you make it executable and run it directly (rather than invoking the python interpreter) then the dock should have the file name. Commented Oct 29, 2020 at 17:18
  • @Novel I do want to change it in the regular python interpreter. I'm still working on the project, but I want to know how to change it without turning it into an .exe or .app. Commented Oct 29, 2020 at 17:21
  • You should try changing CFBundleName to CFBundleDisplayName. I'm not sure, but it would make sense. Commented Oct 29, 2020 at 17:22
  • @dspr nope, CFBundleDisplayName doesn't exist. Commented Oct 29, 2020 at 17:26
  • By "making it executable" I mean setting the executable bit, not converting the file. Commented Oct 29, 2020 at 18:41

2 Answers 2

0

How to run your file directly:

Step 1: make this the first line of your file (aka the "shebang"):

#!/usr/bin/env python3 

Step 2: rename the file to PythonPikachu (note no file extension).

Step 3: run this command in the terminal to make the file executable:

chmod +x PythonPikachu 

Step 4: Profit. Your python file is now a program as far as your OS is concerned. You can run it from the command line like you would any other program

./PythonPikachu 

Or you can make a command file or add the program to a launcher or cron or anything else you do with a program.

Sign up to request clarification or add additional context in comments.

3 Comments

The python launcher still says "Python", even though it treats it like an app.
The idea is to bypass the python launcher. Launch your program directly. Treat it like a program (because it is one), not like a python file.
But you can't bypass the python launcher. I've posted an update on my original post saying what I want.
0

Related: OS X: Setting at runtime the Application name as it appears in Dock and Menu Bar

This should fix the issue, although it is a bit of work.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.