views:

42

answers:

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
+2  A: 

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!

Yuji
THats it! I keep forgetting that principal. THanks
Ronaldo Nascimento