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

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to