dabodemo Commit
Revision 534
Date: 2007-08-13 20:35:53 -0700 (Mon, 13 Aug 2007)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabodemo/changeset/534
Changed:
U trunk/tutorial/dbEditableGrid.py
Log:
I refactored the dbEditableGrid demo I wrote this morning, as I think it shows
in a succinct and readable way a very simple Dabo application, from the creation
of the database, to the defining of the bizobj, to the defining of the ui.
Anyone should be able to follow along with this one.
Diff:
Modified: trunk/tutorial/dbEditableGrid.py
===================================================================
--- trunk/tutorial/dbEditableGrid.py 2007-08-13 18:41:20 UTC (rev 533)
+++ trunk/tutorial/dbEditableGrid.py 2007-08-14 03:35:53 UTC (rev 534)
@@ -1,7 +1,16 @@
+"""
+This 32-line script creates a database with sample data, a bizobj, and
+then shows the data in a ui grid that is editable and saves the data
+back to the underlying table.
+"""
import dabo
dabo.ui.loadUI("wx")
-# create our db and a test table:
+# app:
+app = dabo.dApp(MainFormClass=None)
+app.setup()
+
+# db:
con = dabo.db.dConnection(DbType="sqlite", Database=":memory:")
cur = con.getDaboCursor()
cur.execute("create table customers (id INTEGER PRIMARY KEY, name CHAR, valid
INT)")
@@ -9,7 +18,7 @@
cur.execute("insert into customers (name, valid) values ('John', 1)")
cur.flush()
-# define a biz:
+# biz:
biz = dabo.biz.dBizobj(con)
biz.DataSource = "customers"
biz.KeyField = "id"
@@ -22,9 +31,7 @@
biz.requery()
-# show in a grid:
-app = dabo.dApp(MainFormClass=None)
-app.setup()
+# ui:
frm = dabo.ui.dForm()
grd = dabo.ui.dGrid(frm, DataSource=biz, Editable=True)
grd.addColumn(DataField="id", Caption="Id")
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/dabo-dev/[EMAIL PROTECTED]