Python-Cocoa awakeFromNib

Discussion in 'Mac Programming' started by aarplane, Aug 18, 2008.

  1. aarplane macrumors newbie

    Joined:
    Dec 8, 2005
    Location:
    Canada
    #1
    Hi folks,

    I can't seem to get my program to work when I add the awakeFromNib function to my code.

    Code:
        def awakeFromNib(self):
    	self.someButton.setEnabled_(0)
    	
        @objc.IBAction
        def doSomething_(self, sender):
    	self.someButton.setEnabled_(1)
    It just exits with code 5. No warnings or alerts. The main window doesn't pop up. Yet, when I remove the awakeFromNib, the program runs perfectly (minus the error this is intended to fix).
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    Are you sure someButton is a valid object at that point? That's the first thing I'd check.
     
  3. aarplane thread starter macrumors newbie

    Joined:
    Dec 8, 2005
    Location:
    Canada
    #3
    Yes it is. I changed the setEnabled to 0 when I click run the action doSomething, and it effectively disabled someButton.
     
  4. aarplane thread starter macrumors newbie

    Joined:
    Dec 8, 2005
    Location:
    Canada
    #4
    [RESOLVED]

    Turns out I had an IndentationError. I should have told xCode to use spaces instead of tabs for indentation.
     

Share This Page