Re: [Pythonmac-SIG] Categories for class methods

2005-01-27 Thread Dethe Elza
That's a good tip, I haven't gotten the hang of Cocoa's verbosity yet. The choice of read: was to balance write:. The whole thing started because I found it odd that writing an image to a file was such a convoluted process. In a lot of ways, Cocoa makes things really easy, but when it isn't

Re: [Pythonmac-SIG] Categories for class methods

2005-01-27 Thread Bob Ippolito
On Jan 27, 2005, at 15:24, Dethe Elza wrote: FYI, once I updated PyObjC from svn, my example code worked, thanks again Ronald. ... class NSImage(Category(NSImage)): def rect(self): return (0,0),self.size() @classmethod # for Python2.3 replace with read_ = classmethod(read_) de

Re: [Pythonmac-SIG] Categories for class methods

2005-01-27 Thread Dethe Elza
FYI, once I updated PyObjC from svn, my example code worked, thanks again Ronald. from objc import Category from AppKit import * from os.path import splitext _fileRepresentationMapping = { '.png': NSPNGFileType, '.gif': NSGIFFileType, '.jpg': NSJPEGFileType, '.jpe

Re: [Pythonmac-SIG] Categories for class methods

2005-01-27 Thread Dethe Elza
You totally rock, heading to svn now. Thanks! --Dethe On 27-Jan-05, at 3:32 AM, Ronald Oussoren wrote: On 27-jan-05, at 12:06, Ronald Oussoren wrote: On 27-jan-05, at 6:34, Dethe Elza wrote: On 26-Jan-05, at 8:58 PM, Dethe Elza wrote: class NSImage(Category(NSImage)): def read_(cls, filepath):

Re: [Pythonmac-SIG] Categories for class methods

2005-01-27 Thread Ronald Oussoren
On 27-jan-05, at 12:06, Ronald Oussoren wrote: On 27-jan-05, at 6:34, Dethe Elza wrote: On 26-Jan-05, at 8:58 PM, Dethe Elza wrote: class NSImage(Category(NSImage)): def read_(cls, filepath): return NSImage.alloc().initWithhContentsOfFile_(filepath) read_ = classmethod(read_) er, th

Re: [Pythonmac-SIG] Categories for class methods

2005-01-27 Thread Ronald Oussoren
On 27-jan-05, at 6:34, Dethe Elza wrote: On 26-Jan-05, at 8:58 PM, Dethe Elza wrote: class NSImage(Category(NSImage)): def read_(cls, filepath): return NSImage.alloc().initWithhContentsOfFile_(filepath) read_ = classmethod(read_) er, that should be initWithContentsOfFile_, but still

Re: [Pythonmac-SIG] Categories for class methods

2005-01-26 Thread Dethe Elza
On 26-Jan-05, at 8:58 PM, Dethe Elza wrote: class NSImage(Category(NSImage)): def read_(cls, filepath): return NSImage.alloc().initWithhContentsOfFile_(filepath) read_ = classmethod(read_) er, that should be initWithContentsOfFile_, but still gets the same error even without the ty

[Pythonmac-SIG] Categories for class methods

2005-01-26 Thread Dethe Elza
Hi folks, Is it possible to add class methods to a class using Categories? when I try what appears to me to be the naive way to do it: from objc import Category from AppKit import NSImage class NSImage(Category(NSImage)): def read_(cls, filepath): return NSImage.alloc().initWithhContent