1

I have a secondary window (a sheet) for a dialog controlled by a secondard WindowController. For some reason, the actions never get called in NSObject subclass after the sheet is displayed. I have confirmed and re-linked the actions. The code runs to runModalForWindow_ but then never receives the ok or cancel actions. So the sheet never goes away. What am I missing here? I cant seem to find any pyobjc examples on thier website that does a runModalForWindow_...

    @objc.IBAction
def okSelected(self, sender):
    self.dialogResult = objc.YES
    NSLog("OK")
    #NSApp.endSheet_(self.newTurnWindowOutlet)
    NSApp.stopModalWithCode_(objc.OK)

@objc.IBAction
def cancelSelected(self, sender):
    self.dialogResult = objc.NO
    #NSApp.endSheet_(self.newTurnWindowOutlet)
    NSApp.stopModalWithCode_(objc.NO)

def runSheet(self, parent):
    NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(
        self.newTurnWindowOutlet, parent, None, 
        self.sheetDidEnd_returnCode_contextInfo_, None)
    NSLog("runModelForWindow")
    result = NSApp.runModalForWindow_(self.newTurnWindowOutlet)
    NSLog(str(result))
    NSApp.endSheet_(self.newTurnWindowOutlet)
    self.newTurnWindowOutlet.orderOut_(self)
    return self.dialogResult
3

1 Answer 1

2

Your lines

    @objc.IBAction
    def okSelected(self, sender):

should be

    @objc.IBAction
    def okSelected_(self, sender):

etc. Remember, every colon in an Objective-C selector becomes an _ in Python!

1
  • THats it! I keep forgetting that principal. THanks Feb 14, 2010 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.