I have created a brand new project in XCode and have the following in my AppDelegate.py file:
from Foundation import *
from AppKit import *
class MyApplicationAppDelegate(NSObject):
def applicationDidFinishLaunching_(self, sender):
NSLog("Application did finish launching.")
statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(NSVariableStatusItemLength)
statusItem.setTitle_(u"12%")
statusItem.setHighlightMode_(TRUE)
statusItem.setEnabled_(TRUE)
However, when I launch the application no status bar item shows up. All the other code in main.py and main.m is default.
I had to do this to make it work:
Open MainMenu.xib. Make sure the class of the app delegate is MyApplicationAppDelegate
. I'm not sure if you will have to do this, but I did. It was wrong and so the app delegate never got called in the first place.
Add statusItem.retain()
because it gets autoreleased right away.