On Wednesday, October 13, 2010 06:53:16 pm Carey Gagnon wrote: > I've got an appwizard app where I want to turn one of the PagEdit form > fields to a dropdownlist. > I've followed the little tutorial here: > http://wiki.dabodev.com/HowToPopulateAndUseListControls > and here: > http://leafe.com/archives/msg/342481 > > so that my Records.py biz object file contains this: > > def getTasks(self): > """Return a 2-tuple of lists of the types and their keys.""" > crs = self.getTempCursor() > crs.execute("select id, name from tasks order by name") > ds = crs.getDataSet() > # Create the lists > names = [rec["name"] for rec in ds] > keys = [rec["id"] for rec in ds] > return (names, keys) > > and my ui\PagEditRecord.py file has this: > > mybiz = self.getBizObject("records") > names, keys = mybiz.getTasks() > objectRef = self.addObject(dabo.ui.dDropdownList, > NameBase="taskID", > > DataSource="tasks", DataField="id", ValueMode="Key", > Choices, Keys = mybiz.getTasks()) > > Running the app fails with this traceback: > > C:\normacapps\timeReporting>python timeReporting.py > Traceback (most recent call last): > File "timeReporting.py", line 19, in <module> > import ui > File "C:\normacapps\timeReporting\ui\__init__.py", line 11, in <module> > from FrmRecords import FrmRecords > File "C:\normacapps\timeReporting\ui\FrmRecords.py", line 10, in <module> > from PagEditRecords import PagEditRecords > File "C:\normacapps\timeReporting\ui\PagEditRecords.py", line 73 > DataSource="tasks", DataField="id", ValueMode="Key", Choices, Keys = > mybiz.getTasks()) > SyntaxError: non-keyword arg after keyword arg > > I followed this exactly from the wiki. What am I doing wrong? > > Carey >
I think you want objectRef = self.addObject(dabo.ui.dDropdownList, NameBase="taskID", DataSource="tasks", DataField="id", ValueMode="Key", Choices = Names, Keys = keys) Also be aware that you are associating a field to the control. When the control does not have data the key will be 0 (zero). So you may have to account for the zero. Johnf _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
