Paul McNett wrote:


It is because there's a ton of stuff in dForm's __init__. Specifically, the functionality is in the __init__'s of dFormMixin, dPemMixin, and dObject. Your example above never let the superclass __init__ code run, so among other things the wxFrame never got to be initialized.

This is why, for Dabo code, you never want to override __init__ (and if you do, you need to take responsibility for correctly calling the superclass __init__).

Thank you.

Earlier you suggested changing to use beforeInit in the BaseForm, and that worked perfectly in the tiny, cut-down example I sent. But when I tried to put that back into the real code, it failed; it failed because what is needed is that the dForm is initialized first, then BaseForm should create and layout the controls/sizers, and then the DemoForm can do some further setup on the controls.

Therefore, in the real example,
BaseForm can't use beforeInit - the dForm isn't initialized yet.
It can't easily use __init__ as you explained above
and it can't (simply) use afterInit, because that never gets called (only the afterInit in DemoForm is called).

Here's what I'm currently doing, i.e. calling the BaseForm afterInit explicitly from the DemoForm, and it works, but it seems there might be a better way. Is there an easier way ?

import dabo
dabo.ui.loadUI("wx")

class BaseForm(dabo.ui.dForm):
   def afterInit(self):
       print "base"
       self.done = True
       # create the controls and sizers


class DemoForm(BaseForm):
   def afterInit(self):
BaseForm.afterInit(self) # ensure the controls are created and laid out first
       print "demo", self.done

def main():
   app = dabo.dApp()
   app.MainFormClass = DemoForm
   app.start()

if __name__ == '__main__':
   main()



--
Alex Tweedly       http://www.tweedly.net



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.2/357 - Release Date: 06/06/2006


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to