How to get a correct entry in the menu for a Python application on Mac OS X

D

Detlev Offenbach

Hello,

I am fairly new to Mac OS X and would like to know, what I have to do to
make my Python application show the correct name in the menu bar. What
did I do so far. I created an application package containing the .plist
file with correct entries and a shell script, that starts the correct
Python interpreter with the the main script. The menu bar just shows
Python instead of the name of my application. If you are interested the
application can be found via http://eric-ide.python-projects.org.


Regards,
Detlev
 
G

Gregory Ewing

Detlev said:
I am fairly new to Mac OS X and would like to know, what I have to do to
make my Python application show the correct name in the menu bar. What
did I do so far. I created an application package containing the .plist
file with correct entries and a shell script, that starts the correct
Python interpreter with the the main script.

I don't think that will work, because the executable that
your shell script is starting is in an app bundle of its
own, and MacOSX will be using the plist from that bundle,
which just has the generic "Python" name in it.

There are a couple of things you could do:

1) Use py2app to create your app bundle. It does the
right things -- not sure exactly what, but it works.

2) Hack things at run time. I use the following PyObjC
code in PyGUI to set the application name:

from Foundation import NSBundle

ns_bundle = NSBundle.mainBundle()
ns_info = ns_bundle.localizedInfoDictionary()
if not ns_info:
ns_info = ns_bundle.infoDictionary()
ns_info['CFBundleName'] = my_application_name
 
D

Detlev Offenbach

I got it working by creating a symbolic link to the Python interpreter to
be used in my application package and using this symbolic link to start
the main Python script.


Gregory said:
Detlev said:
I am fairly new to Mac OS X and would like to know, what I have to do
to make my Python application show the correct name in the menu bar.
What did I do so far. I created an application package containing the
.plist file with correct entries and a shell script, that starts the
correct Python interpreter with the the main script.

I don't think that will work, because the executable that
your shell script is starting is in an app bundle of its
own, and MacOSX will be using the plist from that bundle,
which just has the generic "Python" name in it.

There are a couple of things you could do:

1) Use py2app to create your app bundle. It does the
right things -- not sure exactly what, but it works.

2) Hack things at run time. I use the following PyObjC
code in PyGUI to set the application name:

from Foundation import NSBundle

ns_bundle = NSBundle.mainBundle()
ns_info = ns_bundle.localizedInfoDictionary()
if not ns_info:
ns_info = ns_bundle.infoDictionary()
ns_info['CFBundleName'] = my_application_name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top