Hi,
I think I'll start adding small stuff first
Please review and add to the question wiki.


What, why and how of "doDefault()"

What is “doDefault()”?
Executes the parent class event or method of the same name from within a 
subclass.

Why do we have “doDefault()”
Many of the ideas we have in Dabo come from Visual FoxPro programming 
language.  Both Ed Leafe and Paul McNett are VFP programmers as well as many 
of the other Dabo developers.  So it was natural to bring some of the good 
features of VFP to Dabo.  “doDefault()” iis one such feature and is an easy 
way of executing the parent code.

How do I use it?
First I'll create a couple of  fake classes to demo how it works then show a 
real Dabo scenario.

class MyParent:
   def printsomething(self):
          print “I like”

class TheChild(MyParent):
    def printsomething(self):
         self.doDefault()
         print “Dabo”

The output would be 
      “I like”
      “Dabo”

The dDialog class has the “_onEscape” method which captures the “escape” key 
and closes the dialog.  So anything I subclass from the class dDialog will 
have the same “escape” key actions.  The method below is from the dDialog 
Class.

def _onEscape(self, evt):
        if self.ReleaseOnEscape:
                self.release()
                self.Close()


I will create a subclass of dDialog and notice how I identified the parent 
class.  Also notice that  “doDefault()” requires that I pass any parameters 
the parent requires.  In this case I want to set the value of a variable if 
the “escape” key is typed or I could do some other task I might need done 
before passing the program execution to the parent class.

class dynamicDialog(dabo.ui.dDialog):
        def _onEscape(self, evt):
               self.SomeVarVal ="esc"
           print "In the SubClass"
           # Now I pass execution to the parent class along with required 
parameters.   
           self.doDefault(evt)
-- 
John Fabiani

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

Reply via email to