Uwe Grauer wrote: > Paul McNett wrote: >> Uwe Grauer wrote: >>> Paul McNett wrote: >>>> Uwe Grauer wrote: >>>>> Which event is best to use if a Form gets called (shown)? >>>>> Is it onActivate or is there something better? >>>>> I asking to find a better place to initialize my called form with the >>>>> parameters which got set from the parentform. >>>> onActivate will get called whenever the form (re)takes the focus. So if >>>> you use that you should set a flag so that you don't call the same init >>>> code over and over again. >>>> >>> I do this now, with a flag. >>> >>>> You can also try overriding afterInit() or afterInitAll(), which are >>>> hook methods that get called rather late in the init cycle. >>>> >>> Overriding? >>> I thought that afterInit[All] is called after the createForm. >>> >>> This is called to show a childform: >>> def callEditEtyp(self, newrec=False): >>> frmclass = "EditEtyp.cdxml" >>> frm = dabo.ui.createForm(frmclass) >>> frm.parentform = self >>> if newrec: >>> frm.newrec = True >>> frm.etypiid = None >>> else: >>> frm.newrec = False >>> currow = self.dGridEtyp.CurrentRow >>> curiid = self.PrimaryBizobj.getDataSet(rowStart=currow, >>> rows=1)[0]['iid'] >>> frm.etypiid = curiid >>> self.hide() >>> frm.showModal() >>> >>> May i ask some more on how to do it when i come back from my childform? >> You know, you are basically wanting to set properties on your child form >> from the main form, so the best way in your case may be to define >> properties in the child form, and then just pass those properties to the >> constructor. For example: >> >> class ChildForm(dabo.ui.dForm): >> def _getNewRec(self): >> return getattr(self, "_newRec", None) >> def _setNewRec(self, val): >> self._newRec = bool(val) >> NewRec = property(_getNewRec, _setNewRec) >> >> class MainForm(dabo.ui.dForm): >> ... >> def callEditEtyp(self, newrec=False): >> frmclass = "EditEtyp.cdxml" >> frm = dabo.ui.createForm(frmclass, NewRec=newrec) >> ... >> self.hide() >> frm.showModal() >> >> > > Ok, will do. > > Now what's best if i come back from my childform? > > This is called to leave a childform: > def onHit(self, evt): # btnSave > self.Form.save() > parent = self.Form.parentform > parent.dorecquery = True > parent.show() > self.Form.close()
Ooh, you are wishing for truly-modal forms I bet. That way, all that parent code goes in the parent just under the showModal() call. We'll get that modal stuff working soon, I'm sure (I'm going to want it for my current project). In the meantime, I think you have it pretty much how I'd do it, except I don't think I would hide/show the parent form. -- pkm ~ http://paulmcnett.com _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
