1# 2# ITunesCommunication.py 3# PyObjC2Test 4# 5# Created by Jack Jansen on Tue Jun 17 2003. 6# Copyright (c) 2003 __MyCompanyName__. All rights reserved. 7# 8 9import objc 10from Foundation import * 11from AppKit import * 12 13from PyObjCTools import NibClassBuilder 14 15# We tell NibClassBuilder to examine and remember all 16# classes from the CDInfoDocument NIB file. This way, 17# we can subclass our ITunesCommunication from AutoBaseClass 18# later on, and its actual baseclass will be ITunesCommunication 19# from the NIB file. 20# Since the NIB files are in the application, NOT the plugin, we 21# need to specify this explicitly. Typicaly, NIB files would be in the 22# plugins. 23NibClassBuilder.extractClasses("CDInfoDocument", bundle=NSBundle.mainBundle()) 24 25class ITunesCommunication(NibClassBuilder.AutoBaseClass): 26 def init(self): 27 self = super(ITunesCommunication, self).init() 28 if self is None: 29 return None 30 # subclass specific initialization here 31 # nib not loaded yet 32 return self 33 34 def askITunes_(self, obj): 35 # obj is the button the user pressed. We can go from here 36 # to the document (an instance of CDInfoDocument) 37 document = obj.window().windowController().document() 38 document.setBandName_(u"Uit de Sloot") 39 document.setCDTitle_(u"En Snel Een Beetje") 40 document.setMusicGenre_(u"Punkrock") 41