Python と Qt を使用して GUI アプリケーションを作成しています。Mac でアプリケーションを起動すると、画面上部の Mac メニュー バーの最初のメニュー項目が「Python」になります。そこにあるアプリケーション名を自分のアプリケーションの名前にしたいと思います。プログラム名をそこに表示するにはどうすればよいですか?
次のデモ プログラムは、"Python" と "Foo" の 2 つのメニューを含むウィンドウを作成します。私はそれが好きではありません。なぜなら、私がアプリを Python で書いたのか COBOL で書いたのかはユーザーにとって何の違いもないからです。代わりに、メニュー「MyApp」と「Foo」が必要です。
#!/usr/bin/python
# This example demonstrates unwanted "Python"
# application menu name on Mac.
# Makes no difference whether we use PySide or PyQt4
from PySide.QtGui import *
# from PyQt4.QtGui import *
import sys
app = QApplication(sys.argv)
# Mac menubar application menu is always "Python".
# I want "DesiredAppTitle" instead.
# setApplicationName() does not affect Mac menu bar.
app.setApplicationName("DesiredAppTitle")
win = QMainWindow()
# need None parent for menubar on Mac to get custom menus at all
mbar = QMenuBar()
# Add a custom menu to menubar.
fooMenu = QMenu(mbar)
fooMenu.setTitle("Foo")
mbar.addAction(fooMenu.menuAction())
win.setMenuBar(mbar)
win.show()
sys.exit(app.exec_())
Mac でそのアプリケーション メニュー名を変更するにはどうすればよいですか? 編集:可能であれば、システムのpython(またはユーザーPATHにあるpython)を引き続き使用したいと思います。