On Tuesday 24 November 2009 10:40:12 pm jvandal wrote:
> I am trying to run this code. I have a folder simple, and i created a
> I used CnxEditor.py
> to create testy. Is this using dabo to create other than the connection? I
> thought this was to show how t o create a program without using
> ClassDesigner?
Below is a example of handing coding a Dabo a form. It will not run without
you making changes to the code. Such as providing a connection file name, a
real bizobject class, and adding a few controls. But it does provide a
starting point for hand coding a Dabo form.
#/usr/bin/env python
import wx
import dabo
# Always nice to use the date format your users are expecting
dabo.settings.dateFormat ="%m/%d/%Y"
#most likely you will need to use below for buttons and errors
import dabo.dEvents as dEvents
import dabo.dException as dException
#need to provile use below
#from profilehooks import profile, coverage
#load the UI
dabo.ui.loadUI('wx')
#want to capture the keyboard use below
#from dabo.ui import dKeys as dKeys
class MainForm(dabo.ui.dForm):
def createBizobjs(self):
#below is not required because the default is to find all cdxml files.
self.Application.addConnectFile("connectionfilename.cnxml")
# This call will actually create the connection if it hasn't already
# been made. If it has, it returns the existing connection, so that
# multiple connections aren't used up.
self.conn = self.Application.getConnectionByName("connectionname")
class SomeTable_Bizobj(dabo.biz.dBizobj):
#I normally place all my bizobject classes in a file and use
import to retrieve the classes
def initProperties(self):
pass
def afterInit(self):
self.DataSource = "sometable"
self.addFrom( "sometable")
#add some fields
self.addField("inactive")
self.addField("name_1")
self.addField("address")
self.addField("city")
self.addField("state_1")
self.addField("zip")
self.addField("plus4")
self.addField("phone")
self.addField("phoneext")
self.addField("county")
self.addField("notify_1")
self.addField("note")
self.addField("fk_county")
#need to identify the PK
self.addField("pkid")
self.KeyField = "pkid"
self.NonUpdateFields=["pkid"] #use this if your DB
auto-increments the PK
self.DefaultValues={"state_1":'CA'} #set default values for a
new record
def validateRecord(self):
"""Returning anything other than an empty string from
this method will prevent the data from being saved.
"""
ret = ""
# Add your business rules here.
return ret
self.esclient=SomeTable_Bizobj(self.conn)
self.addBizobj(self.esclient)
def afterInit(self):
"""Normally the programmer would add code to display the controls
here. The programmer could add panels that contain other controls etc. """
self.Caption = "Replace with a Window Title"
def afterInitAll(self):
# if you have something that should occur after all is constructed set
it here
pass
def initProperties(self):
# need something set before constructed set it here
pass
if __name__ == "__main__":
app = dabo.dApp()
app.MainFormClass = MainForm #this is normally your opening form class.
app.start()
_______________________________________________
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]