I got something working!  yay!
Now to find out if there is a better way to do this.

# cdxml2objDemo1.py
# cdxml data binding demo #1
# cdxml referencing attributes of a simple class.

class myClass(object):

   """This is nothing more than 2 attributres, a method that does something to 
them, and something close to a unit test."""

   def __init__(self):
     self.myAttrib1 = 'a'
     self.myAttrib2 = 'b'

   def swap(self):
     self.myAttrib1, self.myAttrib2 = self.myAttrib2, self.myAttrib1

   def test(self):
     print self.myAttrib1, self.myAttrib2
     self.swap()
     print self.myAttrib1, self.myAttrib2


import dabo

if __name__ == "__main__":

   app = dabo.dApp(MainFormClass=None)
   app.setup()
   frm = dabo.ui.createForm('bd1.cdxml')
   frm.myObj1=myClass()
   frm.show()
   app.start()

<?xml version = '1.0' encoding = 'utf-8' standalone = 'no'?>
<dForm Top="345" designerClass="DesForm" Width="266" Left="293" Height="85" 
Caption="cdxml 2 obj demo" Name="dForm" UseSizers="True" >
   <dSizer designerClass="LayoutSizer" SlotCount="3" Orientation="Horizontal" >
     <dTextBox sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 
'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" DataField="myAttrib1" 
designerClass="controlMix" DataSource="self.Form.myObj1" />
     <dButton sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 
'Center', 'VAlign': 'Middle', 'Border': 0, 'Expand': False}" 
code-ID="dButton-dForm" designerClass="controlMix" Caption="Swap" />
     <dTextBox sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 
'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" DataField="myAttrib2" 
designerClass="controlMix" DataSource="self.Form.myObj1" Name="dTextBox1" />
   </dSizer>
</dForm>

# -*- coding: utf-8 -*-
# cdxml2objDemo1-code.py

## *!* ## Dabo Code ID: dButton-dForm
def onHit(self, evt):
   self.Form.myObj1.swap()
   self.Form.update()


Carl K


_______________________________________________
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/dabo-users/[EMAIL PROTECTED]

Reply via email to