Re: [Pyobjc-dev] NSTableView
Brought to you by:
ronaldoussoren
From: Birch B. <b.b...@cs...> - 2004-04-04 03:16:07
|
Bob, Thanks for your amazingly fast response. Right now I have a table, dataResults, that I'd like to populate with a list of lists: results = [['string 1', 0.00],['string 2', 1.25],['string 3', 2.75]] Since I'm generating the data, it wouldn't be a problem to use a dictionary: results = [{"Column 1":"string 1","Column 2":0.00},{"Column 1":"string 2","Column 2":1.25},{"Column 1":"string 3","Column 2":2.75}] I'd like to re-write such that the list holds objects to which I can assign values. As in: class Obj(object): def setValueOne(self, valueOne): self.__valueOne = valueOne ... obj = Obj() self.obj.setValueOne(self, valueOne) self.results.append(obj) but, I don't _have_ to do it this way. Since I'm still quite a newbie, you may be able to advise me as the the advantages/disadvantages of each route. I found notes from your presentation online, so I did a little reading about NSArrayControllers. IF I go this route, I think I'd need a little help setting up the bindings in Interface Builder in addition to some controller code. Thanks for any help. Birch On Apr 3, 2004, at 9:06 PM, Bob Ippolito wrote: > > On Apr 3, 2004, at 8:32 PM, Birch Browning wrote: > >> I have a python list that I'd like to use as a data source for a >> table view. >> >> Does anyone have a simple sample they could post? I've tried (and >> tried) to decipher the TableModel example without success. > > If you can depend on OS X 10.3+, then it is exceptionally easy using > Cocoa Bindings. I can create an example that uses them (I actually > did this from scratch in my PyCon presentation) if you want.. > > The real question is what is in your Python list? If it's just > dictionaries with string keys, you hardly have to write any code at > all using Cocoa Bindings. > > -bob > |