Re: [dabo-users] Pass parameters to main form

Author: Ed Leafe

Posted: 2012-01-01 at 19:24:30

On Jan 1, 2012, at 6:07 PM, OKB (not okblacke) wrote:

> How can I add information to tweak this? I'd like to be able to do

> something like:

>

> app = dabo.dApp(MainFormClass=MyForm, projectName="Some project",

> datafile="some file", etc="and so on")

>

> I could of course just add data to MyForm by doing

>

> MyForm.projectName = "Some project"

> MyForm.datafile = "some file"

> MyForm.etc = "and so on"

>

> . . . before starting the app, but that seems rather hackish to me.

> What is the right way in Dabo to specify "extra" information that is

> needed when starting an app or instantiating a control?

The difficulty here is that you want to pass information to the form before the form instance is created. Perhaps you could create a classmethod in your form class that would accept these additional parameters, and store them in class attributes. Then they could be retrieved and acted upon in the __init__() of the form. Something like:

(in the form class)

@classmethod

def storeSetupValues(cls, projectName=None, dataFile=None, ...):

cls.projectName = projectName

cls.datafile = dataFile

...

def __init__(self, ...):

super(MyFormClass, self).__init__(...)

self.doExtraSetup()

def doExtraSetup(self):

self.readDataFile(self.datafile)

...

-- Ed Leafe

_______________________________________________

Post Messages to: Dabo-users@leafe.com

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/48216293-E00E-45F9-9697-8D9BAA9401F0@leafe.com

©2012 Ed Leafe