I am following the apple docs on how to enable menu items according to state in my application :
The doc is at : http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MenuList/Articles/EnablingMenuItems.html%23//apple_ref/doc/uid/20000261-BAJBFGED
I am trying to do something similar to the example code of the method
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem
but in python. The class that holds the actions to the menu items has that method implemented as the docs indicate.
To avoid hardcoding the methodNames in the code I want to compare the result of the action() method to the selector of each method. My code is :
def validateUserInterfaceItem_(self, anItem):
theAction = anItem.action()
if (theAction == self.saveAction_):
Somewhere in the same class I have the method :
def saveAction_(self, sender):
... rest of method definition
To have the selector defined for the above method I also put immediately after the method declaration :
saveAction_ = objc.selector(saveAction_, signature="v@:@")
The problem is that the comparison of the result of anItem.action() does not equals the selector for the method.
If I print both to the terminal using :
I get :
<selector saveAction: of <menubaractions: 0x1010ee000>>
The output does not match. It seems like the representation is different. How do I compare both these values successfully ?