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

PythonPikachu8
  • 359
  • 2
  • 11
  • 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. – Novel Oct 29 '20 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. – PythonPikachu8 Oct 29 '20 at 17:21
  • You should try changing CFBundleName to CFBundleDisplayName. I'm not sure, but it would make sense. – dspr Oct 29 '20 at 17:22
  • @dspr nope, CFBundleDisplayName doesn't exist. – PythonPikachu8 Oct 29 '20 at 17:26
  • By "making it executable" I mean setting the executable bit, not converting the file. – Novel Oct 29 '20 at 18:41
  • 2 years, 3 months later: have you figured out how to change the app name in dock? I'm trying something similar right now, and therefore I got here – ranemirusG Jan 27 '23 at 19:47
  • @ranemirusG nope, never found out – PythonPikachu8 Feb 01 '23 at 13:30

2 Answers2

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.

Novel
  • 13,406
  • 2
  • 25
  • 41
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.

rocksportrocker
  • 7,251
  • 2
  • 31
  • 48