[Pythonmac-SIG] Building a PreferencePane with PyObjC?

David Hain dhain+pythonmac at zognot.org
Sun Apr 19 21:17:05 CEST 2009


On Apr 19, 2009, at 12:01 PM, Bill Janssen wrote:

>> Py2app in subversion already can compile .xib files when building a
>> bundle, unless you use the '-A' flag. In that case you're better of  
>> to
>> instruct Interface builder to save your IB documents as '.nib' files.

FYI, here's a little snippet from one of my setup.py files to add a  
'compile_nib' command. This is what I use to compile my xib files to  
nibs while I'm developing with -A.

import subprocess
import glob
import os
from distutils.core import Command

class CompileNib(Command):
     user_options = []

     def initialize_options(self):
         pass

     def finalize_options(self):
         pass

     def run(self):
         outdir = u'resources/English.lproj'
         if not os.path.exists(outdir):
             os.mkdir(outdir)
         for fn in glob.iglob(u'*.[nx]ib'):
             outfn = os.path.splitext(fn)[0]
             outfile = os.path.join(outdir, outfn + u'.nib')
             subprocess.check_call(['ibtool', '--compile', outfile, fn])


if __name__ == '__main__':
     setup(**dict(setup_args, cmdclass=dict(compile_nib=CompileNib)))


This will find any *.[nx]ib files in the CWD and compile them into the  
resources/English.lproj directory. Should be easy enough to modify.  
All it really does is call 'ibtool --compile' which does the work. To  
use, just run 'python setup.py compile_nib'. Hope this helps!

-David


More information about the Pythonmac-SIG mailing list