On Friday 12 December 2008 09:21:43 am Bob Sysero llc Dev wrote:
> Dabo
>
>   I been working on taking the the HowTo Create a OpenOffice SpreadSheet
> using the Class Designer using three different methods which are:
>
> I   - Entering all the code within the Class Designer.
> II  - Entering the spreadsheet code into the customerBizobj that is
>       in the biz dir and calling the onHit from within the Class
>       Designer.
> III - Last is placing the spreadsheet code in a module in the current
>       project dir and again calling the onHit code within the Class
>       Designer.
>

In the first way (I) you are calling a method from the button click.  You can 
place the method in normally in one or two places either the mainform class 
or in the class were you have defined the button.

class MainForm(dabo.ui.dForm):
 # here you would add your method

def createSpreadSheet(self,evt):
  """ note that I passed the event"""
    do something..

or
class DisplayButton(dabo.ui.dPanel):
  def afterInit(self):
     write code to display the button
     aSizer.append(dabo.ui.dButton(self, Caption='Make Spread', 
OnHit=self.createSpreadSheet)

  def createSpreadSheet(self, evt):
       do something

Of course there are several variations on this:
 for example you could set the OnHit=self.Form.createSpreadSheet
In this case you are calling the method in the MainForm class.  
Ed does not recommend to this - he suggest that button code call form methods.

In the second (II) what you need to do is create the method in the bizobj 
class.  

some where you have something like:
class TableNameBizobj(dabo.biz.dBizobj):
   def afterInit(self):
       self.DataSource = 'TableName'
       self.KeyField = 'somefield'
       self.addField('fieldname') ....

  Now add a new method in the bizobj class:
    def createSpreadSheet(self):
       # because the method is part of the bizobj it is aware of the
       # bizobj data.
       do something.....

from somewhere in the code you need to call the new method.
  # there are many ways to get a bizobj - below just follows what you are 
doing.
  myBizobj = self.getBizobj('TableName')
  myBizobj.createSpreadSheet()

The last (III) can be done as follows.

You need to create a module (file). Let's call it mySpread.py. The easy way is 
to use Dabo's classes.

import oolib
import sys
import re
import locale
import datetime
import decimal
import dabo
import dabo.dEvents as dEvents
#import whatever you need

class CreateSpreadSheet(dObject):
    def createSpreadSheet(pass what is needed):
       do something...


In this case you now need to import your new class
import mySpread as MySpread

Now use the module
myBizobj = self.getBizobj('TableName')

theCustomerDataSet=myBizobj.getDataSet()
MySpread.createSpreadSheet(theCustomerDataSet)

Now from CD.

For (I) you edit the code for the button and say something like
self.Form.createSpread()

Then change the object to the form (it might say DesForm or dForm or a name 
you supplied).

Click the new button and name the new method to match the call.  In this case 
it is 'createSpread'.  Now add your code.

for (II) you now need to edit the file CD created for you for the bizobj.  And 
you just add the code into the class.

for (III) you need to create the module.  Then you need to added the module 
using "Manage Imports".  Some where in the code you the need to use it. 

-- 
John Fabiani


_______________________________________________
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]

Reply via email to