首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在OSX中,将应用程序名从"python“更改为

在OSX中,将应用程序名从"python“更改为
EN

Stack Overflow用户
提问于 2011-02-18 23:42:43
回答 4查看 2.9K关注 0票数 5

我正在开发桔黄色的,在OSX (10.6.5)中,菜单名是'Python‘而不是橙色。这是一个python/qt应用程序。我需要改变什么?

澄清:

  • qt应用程序,不是cli,没有在终端运行。

我的info.plist:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDisplayName</key>
    <string>YOORANGE</string>
        <key>CFBundleExecutable</key>
        <string>Orange</string>
        <key>CFBundleIconFile</key>
        <string>orange.icns</string>
        <key>CFBundleIdentifier</key>
        <string>si.ailab.Orange</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>Orange</string>
        <key>CFBundleGetInfoString</key>
        <string>Orange, component-based data mining software</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleSignature</key>
        <string>Orng</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0.0</string>
        <key>CFBundleVersion</key>
        <string>1.0.0</string>
        <key>CFBundleDocumentTypes</key>
        <array>
                <dict>
                        <key>CFBundleTypeExtensions</key>
                        <array>
                                <string>ows</string>
                        </array>
                        <key>CFBundleTypeName</key>
                        <string>Orange Canvas Schema</string>
                        <key>CFBundleTypeOSTypes</key>
                        <array>
                                <string>OWSf</string>
                        </array>
                        <key>CFBundleTypeIconFile</key>
                        <string>schema.icns</string>
                        <key>CFBundleTypeRole</key>
                        <string>Viewer</string>
                        <key>LSIsAppleDefaultForType</key>
                        <true/>
                </dict>
        </array>
</dict>
</plist>

下面是Orange启动脚本,修改后尝试使用符号链接。显然,有些工作是有用的:)

代码语言:javascript
复制
#!/bin/bash

BUNDLE_DIR=`dirname $0`/../
BUNDLE_DIR=`perl -MCwd=realpath -e 'print realpath($ARGV[0])' $BUNDLE_DIR`/
FRAMEWORKS_DIR="$BUNDLE_DIR"Frameworks/

CANVAS_FILE="$FRAMEWORKS_DIR"Python.framework/Versions/2.6/lib/python2.6/site-packages/orange/OrangeCanvas/orngCanvas.    pyw

cp "$FRAMEWORKS_DIR"Python.framework/Resources/Python.app/Contents/MacOS/{Python-32,AWESOME}
PYTHONEXECUTABLE="$FRAMEWORKS_DIR"Python.framework/Resources/Python.app/Contents/MacOS/AWESOME
PYTHONHOME="$FRAMEWORKS_DIR"Python.framework/Versions/2.6/

#DYLD_FRAMEWORK_PATH="$FRAMEWORKS_DIR"${DYLD_FRAMEWORK_PATH:+:$DYLD_FRAMEWORK_PATH}
DYLD_FRAMEWORK_PATH="$FRAMEWORKS_DIR":"$BUNDLE_DIR"Resources/Qt4/lib${DYLD_FRAMEWORK_PATH:+:$DYLD_FRAMEWORK_PATH}

export PYTHONEXECUTABLE
export PYTHONHOME

export DYLD_FRAMEWORK_PATH
export DYLD_LIBRARY_PATH="$BUNDLE_DIR"Resources/openbabel/lib/:"$BUNDLE_DIR"Resources/openbabel/lib/openbabel/2.2.3/:$    DYLD_LIBRARY_PATH

# LaunchServices passes the Carbon process identifier to the application with -psn paramter - we do not want it
if [[ "$1" == -psn* ]] ; then
 shift
fi

echo "$0"
echo "$PYTHONEXECUTABLE"
echo "$@"

exec -a "$0" "$PYTHONEXECUTABLE" "$CANVAS_FILE" "$@"
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2011-02-20 16:10:48

结果,有一个更深层次的Info.plist捆绑在Contents/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/Info.plist,这是被调用的。

票数 1
EN

Stack Overflow用户

发布于 2019-02-18 21:01:09

我想提出另一个解决办法。它使用Cocoa设置应用程序名称,不需要篡改符号链接。在使用PyQt之前,先在主模块中运行它。

代码语言:javascript
复制
    if sys.platform.startswith('darwin'):
        # Set app name, if PyObjC is installed
        # Python 2 has PyObjC preinstalled
        # Python 3: pip3 install pyobjc-framework-Cocoa
        try:
            from Foundation import NSBundle
            bundle = NSBundle.mainBundle()
            if bundle:
                app_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
                app_info = bundle.localizedInfoDictionary() or bundle.infoDictionary()
                if app_info:
                    app_info['CFBundleName'] = app_name
        except ImportError:
            pass
票数 6
EN

Stack Overflow用户

发布于 2011-02-18 23:58:33

简单的回答--这并不简单,因为您正在运行python解释器,这是它自己的程序,具有自己的默认标题。

长答案-如果环境变量PYTHONSTARTUP设置,Python解释器将在启动时执行shell脚本。您可以在下面设置窗口标题。

  1. 设置环境变量PYTHONSTARTUP,其名称为shell脚本,以便在启动时执行(http://docs.python.org/library/idle.html#startup)
  2. 在该shell脚本中,运行settitle标题。

要获得一个标题,每次你必须做一些额外的环境变量在启动之前改变。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5047734

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档