Index
2012-01-01 19:07 – OKB (not okblacke) : [dabo-users] Pass parameters to main form
2012-01-01 19:24 – Ed Leafe : Re: [dabo-users] Pass parameters to main form
2012-01-01 19:26 – Jacek Kałucki : Re: [dabo-users] Pass parameters to main form
2012-01-01 20:22 – OKB (not okblacke) : Re: [dabo-users] Pass parameters to main form
2012-01-01 21:00 – Ed Leafe : Re: [dabo-users] Pass parameters to main form
2012-01-02 00:10 – Paul McNett : Re: [dabo-users] Pass parameters to main form
2012-01-02 07:16 – Nate Lowrie : Re: [dabo-users] Pass parameters to main form
2012-01-02 10:52 – John Fabiani : Re: [dabo-users] Pass parameters to main form
2012-01-02 11:27 – Ed Leafe : Re: [dabo-users] Pass parameters to main form
2012-01-23 00:46 – OKB (not okblacke) : Re: [dabo-users] Pass parameters to main form
Back to top
[dabo-users] Pass parameters to main form

Author: OKB (not okblacke)

Posted: 2012-01-01 19:07:44   Link

Hi, I'm trying to write a sort of mini-framework that will let me

create many small, similar GUI apps in a streamlined way. (These apps

are actually psycholinguistic experiments -- i.e., experiment subjects

sit down and use the app and it records responses for them for

analysis.)

In so doing, I'd like to be able to pass information into the main

form class for my app. For instance, I'd like to be able to pass it a

list of dPanel subclasses which it will automatically organized into a

sequence that is stepped through as users progress through the

experiment. I found an old post (http://old.nabble.com/Passing-

parameters-td9522965.html) which describes a means of passing

information to a newly-constructed GUI object. However, I can't see how

to do this for the main form of the app, because I don't instantiate

that class directly. I just do:

app = dabo.dApp()

app.MainFormClass = MyForm

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?

Thanks,

--

--OKB (not okblacke)

Brendan Barnwell

"Do not follow where the path may lead. Go, instead, where there is

no path, and leave a trail."

--author unknown

_______________________________________________

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/Xns9FCDA3B917A3EOKB@80.91.229.10

©2012 OKB (not okblacke)
Back to top
Re: [dabo-users] Pass parameters to main form

Author: Ed Leafe

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

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
Back to top
Re: [dabo-users] Pass parameters to main form

Author: Jacek Kałucki

Posted: 2012-01-01 19:26:13   Link

Użytkownik OKB (not okblacke) napisał:

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

> needed when starting an app or instantiating a control?

Personally, I do that this way:

<code>

# Create application

app = App(MainFormClass=None)

...

app.setup()

# Create main form

app.MainForm = app.ui.FrmMain("put parameters here...")

app.startupForms()

# Start the application event loop...

app.start()

</code>

--

Regards

Jacek Kałucki

_______________________________________________

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/4F00F9A5.40404@rz.onet.pl

©2012 Jacek Kałucki
Back to top
Re: [dabo-users] Pass parameters to main form

Author: OKB (not okblacke)

Posted: 2012-01-01 20:22:00   Link

Ed Leafe wrote:

> 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)

> ...

Thanks for your quick reply. I had considered overriding __init__

but it seems a rather extreme solution. It's rather odd that with all

of Dabo's customized initialization stuff (afterInit, afterInitAll,

etc.), there's no hook that allows information to be passed in from the

outside. Anyway, I'll look at doing something like this.

What you mention about passing information before the form instance

is created, though, makes me wonder a bit about the bigger picture. I

suppose it's true that I want to pass information before the instance is

created, but that's only because Dabo hides the instance creation inside

its own innards. It doesn't much matter to me whether I pass my

information when I create the app instance, or when I specify the app's

main form, or when I do app.start(). But, as far as I can tell, at none

of those three places is there a way to pass information in. Is there

some other place to do it? What would it mean to pass it in after the

instance is created? It seems like that would mean passing it in once

the GUI app is already up and running, but that defeats the purpose of

passing it in order to influence initialization.

--

--OKB (not okblacke)

Brendan Barnwell

"Do not follow where the path may lead. Go, instead, where there is

no path, and leave a trail."

--author unknown

_______________________________________________

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/Xns9FCDB0508FDC4OKB@80.91.229.10

©2012 OKB (not okblacke)
Back to top
Re: [dabo-users] Pass parameters to main form

Author: Ed Leafe

Posted: 2012-01-01 21:00:48   Link

On Jan 1, 2012, at 7:22 PM, OKB (not okblacke) wrote:

> Thanks for your quick reply. I had considered overriding __init__

> but it seems a rather extreme solution. It's rather odd that with all

> of Dabo's customized initialization stuff (afterInit, afterInitAll,

> etc.), there's no hook that allows information to be passed in from the

> outside. Anyway, I'll look at doing something like this.

Usually things get added as they are needed. As far as I know, this is the first request for such a behavior, which would explain why the hook hasn't been created. :-)

I wrote that previous solution off the top of my head; another alternative would be to store the params you want the form to receive in a dict attribute of the app itself. Then the only thing you would need to do is change the form to look for anything in self.Application.formParams (or whatever you call it), and process them accordingly. I'm sure that there are a bunch of other approaches, too.

> What you mention about passing information before the form instance

> is created, though, makes me wonder a bit about the bigger picture. I

> suppose it's true that I want to pass information before the instance is

> created, but that's only because Dabo hides the instance creation inside

> its own innards. It doesn't much matter to me whether I pass my

> information when I create the app instance, or when I specify the app's

> main form, or when I do app.start(). But, as far as I can tell, at none

> of those three places is there a way to pass information in. Is there

> some other place to do it? What would it mean to pass it in after the

> instance is created? It seems like that would mean passing it in once

> the GUI app is already up and running, but that defeats the purpose of

> passing it in order to influence initialization.

Like I said above, I don't believe that anyone has ever suggested this approach to customization before. The only thing even close would be forms that read some sort of .ini file or similar when they are created, but that doesn't seem to be what you're doing. You want to be able to create the app with parameters and have the form receive them. Maybe we could add a MainFormParameters property to dApp that would take a dict of params, and these would be passed to the MainFormClass when it is instantiated as its kwargs.

Paul, I'm hoping that you'll chime in here with any thoughts on this approach.

-- 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/302A15C5-287D-4487-8C51-7ECCE9D6D5B8@leafe.com

©2012 Ed Leafe
Back to top
Re: [dabo-users] Pass parameters to main form

Author: Paul McNett

Posted: 2012-01-02 00:10:16   Link

On 1/1/12 6:00 PM, Ed Leafe wrote:

> It doesn't much matter to me whether I pass my

>> information when I create the app instance, or when I specify the app's

>> main form, or when I do app.start(). But, as far as I can tell, at none

>> of those three places is there a way to pass information in. Is there

>> some other place to do it? What would it mean to pass it in after the

>> instance is created? It seems like that would mean passing it in once

>> the GUI app is already up and running, but that defeats the purpose of

>> passing it in order to influence initialization.

How about:

class MyApp(dabo.dApp):

def _getStartupPanels(self):

return getattr(self, "_startupPanels", [])

def _setStartupPanels(self, val):

self._startupPanels = []

StartupPanels = property(_getStartupPanels, _setStartupPanels)

class MyMainForm(dabo.ui.dFormMain):

def afterInit(self):

for P in self.Application.StartupPanels:

p = P(self)

self.Sizer.append(p)

...and in your startup code:

import dabo

dabo.ui.loadUI("wx")

class Panel1(dabo.ui.dPanel):

...

class Panel2(dabo.ui.dPanel):

...

startupPanels = [Panel1, Panel2]

app = MyApp(MainFormClass=MyMainForm, StartupPanels=startupPanels)

app.start()

I haven't tested this but it should work, theoretically.

Paul

_______________________________________________

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/4F013C38.7090509@ulmcnett.com

©2012 Paul McNett
Back to top
Re: [dabo-users] Pass parameters to main form

Author: Nate Lowrie

Posted: 2012-01-02 07:16:24   Link

On 1/1/2012 9:00 PM, Ed Leafe wrote:

> On Jan 1, 2012, at 7:22 PM, OKB (not okblacke) wrote:

>> What you mention about passing information before the form instance

>> is created, though, makes me wonder a bit about the bigger picture. I

>> suppose it's true that I want to pass information before the instance is

>> created, but that's only because Dabo hides the instance creation inside

>> its own innards. It doesn't much matter to me whether I pass my

>> information when I create the app instance, or when I specify the app's

>> main form, or when I do app.start(). But, as far as I can tell, at none

>> of those three places is there a way to pass information in. Is there

>> some other place to do it? What would it mean to pass it in after the

>> instance is created? It seems like that would mean passing it in once

>> the GUI app is already up and running, but that defeats the purpose of

>> passing it in order to influence initialization.

> Like I said above, I don't believe that anyone has ever suggested this approach to customization before. The only thing even close would be forms that read some sort of .ini file or similar when they are created, but that doesn't seem to be what you're doing. You want to be able to create the app with parameters and have the form receive them. Maybe we could add a MainFormParameters property to dApp that would take a dict of params, and these would be passed to the MainFormClass when it is instantiated as its kwargs.

>

> Paul, I'm hoping that you'll chime in here with any thoughts on this approach.

I know I have been doing this on my dialog forms for years to

automatically pass in the bizobj. I just override the init method.

Probably not the best solution, but it works for me.

There are some other ways to approach this. You could make the panel

list a property on the form and set it outside of the init method. This

would require an extra line but decouples things a bit and is more

flexible. If I am not mistaken, you can also not pass it into the

constructor and the property setting logic will properly pick it up.

The last way to do this is to use a plugin manager like Yapsy to manage

the panel set for you. Your form would look for the plugin manager on

instantiation and find all of the panels and add them to the form. I am

actually moving this way for most all my applications and am almost

there. The nice part about this is you can now have a standard

application template and you just add panel plugins. Makes everything

very convenient. However, fair warning, this will be a good bit more

work to get up an running than the other methods.

Regards,

Nate

I also have

_______________________________________________

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/4F01A018.9040003@gmail.com

©2012 Nate Lowrie
Back to top
Re: [dabo-users] Pass parameters to main form

Author: John Fabiani

Posted: 2012-01-02 10:52:42   Link

On Monday, January 02, 2012 07:16:24 AM Nate Lowrie wrote:

> On 1/1/2012 9:00 PM, Ed Leafe wrote:

> > On Jan 1, 2012, at 7:22 PM, OKB (not okblacke) wrote:

> >> What you mention about passing information before the form

> >> instance

> >>

> >> is created, though, makes me wonder a bit about the bigger picture. I

> >> suppose it's true that I want to pass information before the instance

> >> is

> >> created, but that's only because Dabo hides the instance creation

> >> inside

> >> its own innards. It doesn't much matter to me whether I pass my

> >> information when I create the app instance, or when I specify the

> >> app's

> >> main form, or when I do app.start(). But, as far as I can tell, at

> >> none

> >> of those three places is there a way to pass information in. Is there

> >> some other place to do it? What would it mean to pass it in after the

> >> instance is created? It seems like that would mean passing it in once

> >> the GUI app is already up and running, but that defeats the purpose of

> >> passing it in order to influence initialization.

> >>

> > Like I said above, I don't believe that anyone has ever suggested this

> > approach to customization before. The only thing even close would be

> > forms that read some sort of .ini file or similar when they are

> > created, but that doesn't seem to be what you're doing. You want to

> > be able to create the app with parameters and have the form receive

> > them. Maybe we could add a MainFormParameters property to dApp that

> > would take a dict of params, and these would be passed to the

> > MainFormClass when it is instantiated as its kwargs.

> >

> > Paul, I'm hoping that you'll chime in here with any thoughts on this

> > approach.

> I know I have been doing this on my dialog forms for years to

> automatically pass in the bizobj. I just override the init method.

> Probably not the best solution, but it works for me.

>

> There are some other ways to approach this. You could make the panel

> list a property on the form and set it outside of the init method. This

> would require an extra line but decouples things a bit and is more

> flexible. If I am not mistaken, you can also not pass it into the

> constructor and the property setting logic will properly pick it up.

>

> The last way to do this is to use a plugin manager like Yapsy to manage

> the panel set for you. Your form would look for the plugin manager on

> instantiation and find all of the panels and add them to the form. I am

> actually moving this way for most all my applications and am almost

> there. The nice part about this is you can now have a standard

> application template and you just add panel plugins. Makes everything

> very convenient. However, fair warning, this will be a good bit more

> work to get up an running than the other methods.

>

> Regards,

>

> Nate

I normally just setup some properties for dialogs - In Nate's case Larry and I

came up with the following to pass the main form:

class NewPayment(dabo.ui.dDialog):

def _getMainForm(self):

return getattr(self, "_MainForm", None)

def _setMainForm(self, val):

self._MainForm = val

MainForm = property(_getMainForm, _setMainForm)

The you can all the dialog

newDialog = NewPayment(MainForm = self)

newDialog.ShowModal()

Johnf

_______________________________________________

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/5100272.0q3Dc8MxBx@linux-12

©2012 John Fabiani
Back to top
Re: [dabo-users] Pass parameters to main form

Author: Ed Leafe

Posted: 2012-01-02 11:27:44   Link

On Jan 2, 2012, at 6:16 AM, Nate Lowrie wrote:

> I know I have been doing this on my dialog forms for years to

> automatically pass in the bizobj. I just override the init method.

> Probably not the best solution, but it works for me.

Completely different issue. He needs to pass this information to the initial form created as the application starts up. There is currently no direct way to specify initial form parameters when starting an app.

-- 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/DED78887-D0A9-401C-8C1C-93489D003FE3@leafe.com

©2012 Ed Leafe
Back to top
Re: [dabo-users] Pass parameters to main form

Author: OKB (not okblacke)

Posted: 2012-01-23 00:46:48   Link

Paul McNett wrote:

> On 1/1/12 6:00 PM, Ed Leafe wrote:

>> It doesn't much matter to me whether I pass my

>>> information when I create the app instance, or when I specify

>>> the app's main form, or when I do app.start(). But, as far as I

>>> can tell, at none of those three places is there a way to pass

>>> information in. Is there some other place to do it? What would

>>> it mean to pass it in after the instance is created? It seems

>>> like that would mean passing it in once the GUI app is already

>>> up and running, but that defeats the purpose of passing it in

>>> order to influence initialization.

>

> How about:

>

> class MyApp(dabo.dApp):

> def _getStartupPanels(self):

> return getattr(self, "_startupPanels", [])

> def _setStartupPanels(self, val):

> self._startupPanels = []

> StartupPanels = property(_getStartupPanels, _setStartupPanels)

Coming back to this after a few weeks, during which I tried various

solutions. . .

The solution you provide above is fine as far as it goes, but that

seems like an awful lot of boilerplate to me just to pass a parameter

into my app. I would also have to do the same for each individual

parameter I want to pass.

I realized that the info I want to pass in doesn't necessarily have

to be on the form class. In particular, I'm fine with it being handled

by the dApp instance. There doesn't seem to be any way to pass

parameters in at App creation time either, though. So what I did was

subclass dApp and override __init__ so it accepts additional arguments.

I get the sense from postings on this list that overriding __init__ on

Dabo classes is a bit dicey, though (hence the existence of afterInit

and such methods).

This seems to meet my needs for now, although I'd be interested to

hear if this is thought to be the wrong way to do it.

--

--OKB (not okblacke)

Brendan Barnwell

"Do not follow where the path may lead. Go, instead, where there is

no path, and leave a trail."

--author unknown

_______________________________________________

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/Xns9FE2DDB639DFCOKB@80.91.229.10

©2012 OKB (not okblacke)