Setting Mac OSX Application Menu menu bar item to other than “Python” in my python Qt application

后端 未结 6 1577
灰色年华
灰色年华 2020-12-05 14:45

I am writing a GUI application using python and Qt. When I launch my application on Mac, the first menu item in the Mac menu bar at the top of the screen is \"Python\". I

6条回答
  •  暖寄归人
    2020-12-05 15:25

    I have found the kernel of an answer to this question. Because I want to award the bounty to someone other than myself (I am the OP), please, anyone, take this kernel and elaborate it into a more complete answer of your own.

    I can get the application menu to be "MyApp" as follows:

    ln -s /System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python MyApp
    
    ./MyApp MyApp.py
    

    There are two elements required to get this to work:

    1. The symbolic link must be named "MyApp" (or whatever you want to appear in the Application Menu)
    2. The symbolic link must point to the Python executable inside the system python app bundle. It does not work if you link to /usr/bin/python, for example.

    There must be a clever way to create an app bundle or shell script that exploits this mechanism in a robust way...

提交回复
热议问题