wxGrid update / Dabo

Paul,

I'm sure I'm just one of many who are trying out dabo for the first time. Unfortunately, the sample code fails at
  >>> grd.addColumn(Caption = "Last Name", DataField = "last_name")
  TypeError: addColumn() got an unexpected keyword argument 'Caption'
For us newbies, what's the right way to do this? Do we need to create some dColumns first and add them (tried it, didn't work).

Thanks,

Steve

···

Subject:
Re: [wxPython-users] wxGrid update
From:
Paul McNett <p@ulmcnett.com>
Date:
Tue, 16 May 2006 11:11:39 -0700
To:
wxPython-users@lists.wxwidgets.org

To:
wxPython-users@lists.wxwidgets.org

If you are new to wxPython it may be early enough to convince you to give Dabo a try. Dabo is a 3-tier database application development framework, where the UI tier wraps wxPython into a simplified layer.

http://dabodev.com

You can forget about using the db and biz tiers and just use the ui tier instead of using wxPython directly, and your grid problem can be solved with the following code:

#-- begin sample code

import dabo
dabo.ui.loadUI("wx")

app = dabo.dApp()
app.setup()

# populate your dataset from a database, but here's a sample:
ds = ({"last_name": "McNett", "first_name": "Paul"},
      {"last_name": "Bundy", "first_name": "Bud"})

grd = app.MainForm.addObject(dabo.ui.dGrid)
grd.DataSet = ds
grd.addColumn(Caption="Last Name", DataField="last_name")
grd.addColumn(Caption="First Name", DataField="first_name")

app.start()

#-- end sample code

Click on the column headers to sort, type into the grid to search.

Steve Staneff wrote:

Paul,

I'm sure I'm just one of many who are trying out dabo for the first time. Unfortunately, the sample code fails at
    >>> grd.addColumn(Caption = "Last Name", DataField = "last_name")
    TypeError: addColumn() got an unexpected keyword argument 'Caption'
For us newbies, what's the right way to do this? Do we need to create some dColumns first and add them (tried it, didn't work).

Sorry, I forgot that it was only in the dev branch that we added the feature of passing the properties to addColumn(). Rest assured, the code I posted works in Dabo 0.7, but not in 0.6.

Yes, you need to create your dColumns first and then add them. Here is some tested code:

import dabo
dabo.ui.loadUI("wx")

app = dabo.dApp()
app.setup()

# populate your dataset from a database, but here's a sample:
ds = ({"last_name": "McNett", "first_name": "Paul"},
       {"last_name": "Bundy", "first_name": "Bud"})

grd = app.MainForm.addObject(dabo.ui.dGrid)
grd.DataSet = ds
col = dabo.ui.dColumn(grd, Caption="Last Name", DataField="last_name")
grd.addColumn(col)
col = dabo.ui.dColumn(grd, Caption="First Name", DataField="first_name")
grd.addColumn(col)
grd.autoSizeCol("all")

app.start()

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com