This is the code setup for my Step by Step guide project.
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> import dabo
> dabo.ui.loadUI("wx")
>
> app = dabo.dApp()
>
> # IMPORTANT! Change app.MainFormClass value to the name
> # of the form class that you want to run when your
> # application starts up.
> #app.MainFormClass = dabo.ui.dFormMain
> #app.MainFormClass = "ui/ClientForm.cdxml"
> app.MainFormClass = "ui/HoursForm.cdxml"
>
> app.start()
> Code for project:
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> import dabo
>> import datetime
>>
>> class BizHours(dabo.biz.dBizobj):
>> def afterInit(self):
>> self.DataSource = "hours"
>> self.KeyField = "pkid"
>> self.addField("hours.pkid")
>> self.addField("hours.clientfk")
>> #self.addField("clients.clientname")
>> self.addField("hours.servicedate")
>> self.addField("hours.hours")
>> self.addField("hours.notes")
>> self.addField("hours.billed")
>> self.addFrom("hours")
>> self.addJoin("clients", "hours.clientfk = clients.pkid")
>> self.DefaultValues = {"servicedate": datetime.date.today()}
>>
>> def getClients(self):
>> """Return a 2-tuple of lists of the client names and their
>> keys."""
>> crs = self.getTempCursor()
>> crs.execute("select pkid, clientname from clients order by
>> clientname")
>> ds = crs.getDataSet()
>> # Create the lists
>> names = [rec["clientname"] for rec in ds]
>> keys = [rec["pkid"] for rec in ds]
>> return (names, keys)
>> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> import dabo
>>
>> class BizClient(dabo.biz.dBizobj):
>> def afterInit(self):
>> self.DataSource = "clients"
>> self.KeyField = "pkid"
>> self.SQL = """select pkid, clientname, attn, rate, street1,
>> street2,
>> city, stateprov, postalcode
>> from clients
>> """
>> # -*- coding: utf-8 -*-
>> ### Dabo Class Designer code. You many freely edit the code,
>> ### but do not change the comments containing:
>> ### 'Dabo Code ID: XXXX',
>> ### as these are needed to link the code to the objects.
>>
>> ## *!* ## Dabo Code ID: dButton-dPage-462
>> def onHit(self, evt):
>> self.Form.close()
>>
>>
>>
>> ## *!* ## Dabo Code ID: dButton-dPage
>> def onHit(self, evt):
>> self.Form.save()
>>
>>
>>
>> ## *!* ## Dabo Code ID: dButton-dPage-651
>> def onHit(self, evt):
>> self.Form.cancel()
>>
>>
>>
>> ## *!* ## Dabo Code ID: dForm-top
>> def afterInitAll(self):
>> self.new()
>>
>> def afterSave(self):
>> self.new()
>> self.servicedate.setFocus()
>>
>> def createBizobjs(self):
>> conn = self.Application.getConnectionByName("Hours")
>> bizHours = self.Application.biz.BizHours(conn)
>> self.addBizobj(bizHours)
>>
>>
>>
>> ## *!* ## Dabo Code ID: dDropdownList-dPage
>> def afterInit(self):
>> biz = self.Form.getBizobj("hours")
>> names, pks = biz.getClients()
>> self.Choices = names
>> self.Keys = pks
>> self.valueMode = "Key"
>> print 'name',names
>> print 'key',pks
>>
>> <?xml version="1.0" encoding="utf-8" standalone="no"?>
>> <dForm code-ID="dForm-top" CxnFile="..\db\consulthours.cnxml"
>> Name="dForm" Caption="Hours" Top="220" Height="550" Width="570"
>> designerClass="DesForm" CxnName="Hours" UseSizers="True" Left="355">
>> <dSizer SlotCount="1" designerClass="LayoutSizer"
>> Orientation="Vertical">
>> <dPageFrame sizerInfo="{'Proportion': 1, 'HAlign': 'Center',
>> 'VAlign': 'Middle', 'Expand': True}" designerClass="controlMix"
>> PageCount="2">
>> <dPage Caption="Data Entry" designerClass="controlMix"
>> Name="dPage">
>> <dSizer SlotCount="2" designerClass="LayoutSizer"
>> Orientation="Vertical">
>> <dGridSizer HGap="3" sizerInfo="{'Expand': True}"
>> Rows="5" designerClass="LayoutGridSizer" VGap="13" Columns="2">
>> <dLabel sizerInfo="{'ColSpan': 2,
>> 'Proportion': 0, 'HAlign': 'Center', 'ColExpand': True, 'VAlign':
>> 'Middle', 'Expand': False, 'RowExpand': True}" Caption="Add Consult
>> Hours" rowColPos="(0, 0)" Height="25" Width="174" ForeColor="(0, 0,
>> 255)" FontSize="16" designerClass="controlMix"></dLabel>
>> <dLabel sizerInfo="{'Proportion': 0,
>> 'HAlign': 'Right', 'ColExpand': True, 'Expand': False, 'RowExpand':
>> True}" Name="dLabel1" Caption="Date" rowColPos="(1, 0)" Height="19"
>> Width="50" ForeColor="(0, 0, 255)" FontSize="12"
>> designerClass="controlMix"></dLabel>
>> <dLabel sizerInfo="{'Proportion': 0,
>> 'HAlign': 'Right', 'ColExpand': True, 'Border': 2, 'Expand': False,
>> 'RowExpand': True}" Name="clientLabel" Caption="Client"
>> rowColPos="(2, 0)" Height="19" Width="50" ForeColor="(0, 0, 255)"
>> FontSize="12" designerClass="controlMix"></dLabel>
>> <dLabel sizerInfo="{'Proportion': 0,
>> 'HAlign': 'Right', 'ColExpand': True, 'Expand': False, 'RowExpand':
>> True}" Name="hoursLabel" Caption="Hours" rowColPos="(3, 0)"
>> Height="19" Width="50" ForeColor="(0, 0, 255)" FontSize="12"
>> designerClass="controlMix"></dLabel>
>> <dLabel sizerInfo="{'Proportion': 0,
>> 'HAlign': 'Right', 'ColExpand': True, 'Expand': False, 'RowExpand':
>> True}" Name="notesLabel" Caption="Notes" rowColPos="(4, 0)"
>> Height="19" Width="50" ForeColor="(0, 0, 255)" FontSize="12"
>> designerClass="controlMix"></dLabel>
>> <dDateTextBox sizerInfo="{'Proportion': 0,
>> 'ColExpand': True, 'Expand': False, 'RowExpand': True}"
>> rowColPos="(1, 1)" designerClass="controlMix" DataSource="hours"
>> RegID="servicedate" ToolTipText="Available Keys:
>> =============
>> T : Today
>> + : Up One Day
>> - : Down One Day
>> [ : Up One Month
>> ] : Down One Month
>> M : First Day of Month
>> H : Last Day of montH
>> Y : First Day of Year
>> R : Last Day of yeaR
>> C: Popup Calendar to Select
>> " DataField="servicedate"></dDateTextBox>
>> <dDropdownList code-ID="dDropdownList-dPage"
>> sizerInfo="{'Proportion': 0, 'ColExpand': True, 'Expand': False,
>> 'RowExpand': True}" rowColPos="(2, 1)" Choices="[]"
>> designerClass="controlMix" DataSource="hours"
>> DataField="clientfk"></dDropdownList>
>> <dSpinner sizerInfo="{'Proportion': 0,
>> 'ColExpand': True, 'Expand': False, 'RowExpand': True}"
>> rowColPos="(3, 1)" Width="80" designerClass="controlMix"
>> DataField="hours" DataSource="hours"></dSpinner>
>> <dEditBox sizerInfo="{'ColExpand': True,
>> 'Expand': False, 'RowExpand': True}" rowColPos="(4, 1)" Height="120"
>> Width="250" designerClass="controlMix" DataSource="hours"
>> DataField="notes"></dEditBox>
>> </dGridSizer>
>> <dSizer SlotCount="4" sizerInfo="{'Border': 15,
>> 'Expand': True}" designerClass="LayoutSizer" Orientation="Horizontal">
>> <dButton code-ID="dButton-dPage"
>> Caption="Save" sizerInfo="{'HAlign': 'Center', 'VAlign': 'Middle',
>> 'Border': 8}" designerClass="controlMix" Name="btnSave"></dButton>
>> <dButton code-ID="dButton-dPage-651"
>> Caption="Cancel" sizerInfo="{'HAlign': 'Center', 'VAlign': 'Middle',
>> 'Border': 8}" designerClass="controlMix" Name="btnCancel"></dButton>
>> <dPanel Spacing="10"
>> sizerInfo="{'Proportion': 0, 'HAlign': 'Center', 'VAlign': 'Middle',
>> 'Expand': False}" designerClass="LayoutSpacerPanel"></dPanel>
>> <dButton code-ID="dButton-dPage-462"
>> Caption="Close" sizerInfo="{'HAlign': 'Center', 'VAlign': 'Middle',
>> 'Border': 8}" designerClass="controlMix" Name="btnClose"></dButton>
>> </dSizer>
>> </dSizer>
>> </dPage>
>> <dPage Caption="Summary" designerClass="controlMix"
>> Name="dPage1">
>> <dSizer SlotCount="2" designerClass="LayoutSizer"
>> Orientation="Vertical">
>> <dGrid ColumnCount="5" SelectionMode="Cell"
>> designerClass="controlMix" DataSource="hours"
>> sizerInfo="{'Proportion': 2, 'Expand': True}">
>> <dColumn Caption="Work Date"
>> DataField="servicedate" designerClass="controlMix" Order="0"
>> Width="73"></dColumn>
>> <dColumn Caption="Client"
>> DataField="clientfk" designerClass="controlMix" Order="10"
>> Width="120"></dColumn>
>> <dColumn Caption="Hours" DataField="hours"
>> designerClass="controlMix" Order="20" Width="73"></dColumn>
>> <dColumn Caption="Invoiced"
>> DataField="billed" designerClass="controlMix" Order="30"
>> Width="62"></dColumn>
>> <dColumn Caption="Notes" DataField="notes"
>> designerClass="controlMix" Order="40" Width="278"></dColumn>
>> </dGrid>
>> <dPanel sizerInfo="{'Border': 5}"
>> designerClass="LayoutPanel"></dPanel>
>> </dSizer>
>> </dPage>
>> </dPageFrame>
>> </dSizer>
>> </dForm>
>
_______________________________________________
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]