Title: Signature.html
Ah, ha. Good old polymorphism (from my long gone C++ days). Back to the book, old Lutz.  I'll try the print.  Thanks. I'll check out  tkSimpleDialog's description in one of the several pdfs I have on Tk. 

Alan Gauld wrote:

"Wayne Watson" <[email protected]> wrote
Ah, another function without a link to a use. body, as in :

class SetDecoderDialog(tkSimpleDialog.Dialog):
   def body(self,master):
       self.title("Set Video Decoder Register")

       Label(master, text='Register:').grid(row=0, sticky=W)
       Label(master, text='New Value:').grid(row=1, sticky=W)

       self.reg = Entry(master, width=10)
       self.val = Entry(master, width=10)

       self.reg.grid(row=0, column=1, sticky=W)
       self.val.grid(row=1, column=1, sticky=W)

       return self.reg

   def apply(self):
       reg = eval(self.reg.get())
       val = eval(self.val.get())
       self.gui.SetDecoder( reg, val )

That's the end of the class. Is there something going on here between body-apply and tkSimpleDialog? Making them available to it?

Yes. This is part of the power of OOP.
If we create an instance of this class it inherits all of the methods of simpleDialog. But if one of those methods internally calls self.body or self.apply it will  for this instance execute
SetDecoderDialog.body or SetDecoderDialog.apply

This is a form of polymorphism which is commonly used in object frameworks.

Now I don't know whether SimpleDialog does do that but it is entirely possible. Thus it would not seem like anything is calling those two functions but in fact they are being called indirectly. (A couple of print statements would show whether they were or not!)

HTH,


--
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
            
The Richard Feynman Problem-Solving Algorithm:
  (1) write down the problem;
  (2) think very hard;
  (3) write down the answer.

                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to