[Pythonmac-SIG] Possibly OT: Get path to icon file for PIL?
Kevin Walzer
kw at codebykevin.com
Thu Jan 3 23:08:43 CET 2008
I'm looking for a Python API that will return the path to an icon file
which I can then read via PIL and display in my application.
The available API's that I can find--NSWorkspace and
IconServices--provide various hooks to obtaining and displaying an icon,
but neither appears to support finding the source file for an icon. For
instance, I can use something like this in Cocoa to get an icon:
NSWorkspace * ws = [NSWorkspace sharedWorkspace];
NSString * path = [ws fullPathForApplication:@"Safari"];
NSImage * icon = [ws iconForFile: path];
but while this obtains the icon data, it doesn't tell me where the
original file is.
My purpose here is to take advantage of PIL's ability to read icns files
without having to rewrite my application entirely in PyObjC.
Would another approach work? I've looked into using plistlib to parse
plist files, but that seems too haphazard. AppleScript also lists an API
for finding icons, but it's not implemented.
Any advice is appreciated.
--Kevin
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
More information about the Pythonmac-SIG
mailing list