On Monday 06 October 2008 03:39:36 pm Mike Mabey wrote:
> On Fri, Oct 3, 2008 at 5:08 PM, Ed Leafe <[EMAIL PROTECTED]> wrote:
> >        It's certainly possible to do what you ask, but not as simple as
> > with
> > a regular form, with its built-in data awareness. What do you need to
> > do exactly? Perhaps we could come up with an alternative approach that
> > would be easier to implement.
>
> Well, my main app has a few fields that I was hoping to be able to fill by
> opening a child form (acting like a dialog) which would present the options
> for that field in a more consice way.  I actually have the forms already
> set up to transmit the data between forms, except that, of course, the
> parent doesn't wait for the child to close before attempting to retrieve
> the selected info.
>
> Writing the above gave me an idea for a workaround that actually worked.  I
> don't know how Pythonic it is, but it works.  Instead of depending on the
> parent form to wait for the child to close before processing what the user
> did in it, just before the form is closed I call a method in the parent
> form with the selected value passed as a parameter, then the child form
> closes itself.  Here's the code for my "OK" button:
>
> def onHit(self, evt):
>     self.Form.Parent.setSelectedItem(self.Form.CategoryText.Value)
>     self.Form.close()
>
> Where setSelectedItem then sets the target text box's value in the parent
> form to the selected value in the child form.  I hope that made sense... I
> never know how much detail is sufficient.  But now the only thing I'm
> really missing is having the parent form not select-able while the child is
> visible.
>
> Any thoughts or style corrections on my approach?
>
> Thanks for your help,
> Mike M.

I'm not to sure I follow what you are doing with onHit().  But maybe the code 
below will help.  When you pass the dForm to the dialog you can access 
everything the form has such as bizobj's, or any properties required.

import dabo
import wx
dabo.ui.loadUI('wx')
class myDialog(dabo.ui.dDialog):
    def __init__(self, callingForm,*args, **kwargs):
        self.callform=callingForm  ## init the passing fields before the super
        super(myDialog,self).__init__(*args, **kwargs)
        
        
    def addControls(self):
        self.Sizer = vs = dabo.ui.dSizer('v')
        aPanel=dabo.ui.dPanel(self)
        vs.append(aPanel)
        hs=dabo.ui.dSizer('h')
        hs.append(dabo.ui.dLabel(self,Caption='Calling caption'))
        hs.append1x(dabo.ui.dTextBox(self,RegID='callfromID'))
        self.callfromID.Value=self.callform.Caption
        vs.append(hs)
        okbutton=dabo.ui.dButton(self, Caption='Ok')
        cancelbutton=dabo.ui.dButton(self, Caption='Cancel')
        hs1=dabo.ui.dSizer('h')
        hs1.append(okbutton)
        hs1.append(cancelbutton)
        vs.append(hs1)
        
        
class MainForm(dabo.ui.dForm):
    def afterInitAll(self):
        aDialog=myDialog(self)  ## passed the form to dialog
        aDialog.showModal()
        
    
if __name__ == "__main__":
    app = dabo.dApp()
    app.MainFormClass = MainForm
    app.start()




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