[Pyobjc-dev] NSWindow launched from statusItem menuItem does not appear
Brought to you by:
ronaldoussoren
|
From: David M. <da...@my...> - 2008-10-05 15:53:55
|
Hi,
I have a statusItem based application written in PyObjC. The
statusItem has a menuItem which is supposed to launch a new window
when it is clicked.
In my AppDelegate.py
...
menuitem =
NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Preferences',
'launchPreferences:', '')
menu.addItem_(menuitem)
...
The launchPreferences method:
def launchPreferences_(self, notification):
NSLog('AppDelegate: launchPreferences')
self.preferences = Preferences.alloc().init()
self.preferences.showWindow_(self)
which is creating a new object from Preferences.py
class Preferences(NSWindowController):
where I have:
def init(self):
NSLog('Preferences: init')
self = super(Preferences, self).init()
self.initWithWindowNibName_('Preferences')
return self
When I run the application in XCode (Build & Go), this works fine.
However, when I run the built .app file externally from XCode, the
statusItem and menuItem appear as expected but when I click on the
Preferences menuItem the window does not appear. I have verified that
the launchPreferences code is running by checking console output.
Further, if I then double click the .app file again, the window
appears but if I change the active window away by clicking, for
example, on a Finder window, the preferences window disappears. This
seems to me to be something to do with the active window.
I have tried using makeKeyAndOrderFront_() and
setLevel_(NSNormalWindowLevel) on the Preferences object but these
seem to be NSWindow methods and I just get 'Preferences' object has no
attribute errors.
Am I going wrong somewhere? You can check out the whole project at http://code.google.com/p/gfgain/source/browse/trunk/
--
David Mytton
www.mytton.net / www.econversions.co.uk
|