Audio of My UTOSC Presentation
I gave a presentation this past fall at UTOSC about various programming tips I've learned while I worked on Oggify. The audio from this was recorded and is now available. Enjoy.
Building Cocoa GUIs in Python with PyObjC, Part Six
Handling Images
Cocoa provides an easy interface for dealing with images, NSImage. It can be a bit tricky in Python, but once you get it right the first time, it is fairly easy. For our application we have the images stored inside the audio tags and need to populate an NSImage object from binary data stored as a Python byte-string.
There are a number of methods for initializing an NSImage object from various sources. A few of note:
initWithContentsofFile:
initWithData:
initWithPasteboard:
All of these are worth reading about in the developer documentation. We will be using initWithData:. This accepts a NSData object to make the NSImage. This is a multiple step process, so we'll create a method to make things easier:
def buildNSImage(bytes):
data = NSData.dataWithBytes_length_(bytes, len(bytes))
return NSImage.alloc().initWithData_(data)
bytes is a Python byte-string containing the image. NSImage will automatically handle the formatting ...
Best of 2008
This is out of the norm of my blog posts, but it being the end of the year I thought I'd mention some things I've found to be really good this year. I recommend these things to anyone.
Music
"Life in Technicolor," by Coldplay, from Viva la Vida
The first track from their new album. No actual lyrics, but great music. I've listened to it more than any other track on the album. Go buy it on Amazon or iTunes and enjoy 2 minutes of great music.
Weezer, by Weezer
The Red Album was really good. I had the chance to see Weezer in concert this fall, and I'm still sold on how great a band they are. Rivers does a lot of interesting stuff on this album, but I especially enjoy "The Greatest Man Who Ever Lived."
Video Games
Penny Arcade Adventures, On the Rain-Slick ...

