質問

I am programmatically creating a menu in PyObjC with this hierarchy.

NSMenu (setMainMenu on NSApplication)
- NSMenuItem(1)
  - NSMenu: "App Name"
    - NSMenuItem(1)
    - NSMenuItem(2)
    ...
- NSMenuItem(2)
  - NSMenu: "File"
    - NSMenuItem(1)
    - NSMenuItem(2)
    ...
- NSMenuItem(3)
  - NSMenu: "Edit"
    - NSMenuItem(1)
    - NSMenuItem(2)
    ...
...

However, all PyObjC app shows is a single "Python" menu, that contains items that ought to be under "App Name".

How do I make it behave?

役に立ちましたか?

解決

The "Python" menu is likely the menu from the MainMenu.nib in the Python.app application hidden in Python.framework. That application makes it possible to use GUI APIs in a command-line script without having to resort to private APIs.

The best way to get the proper behavior is to create an application bundle, either through py2app or manually.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top