[Tutor] a question based on Sheila's Tkinter class defn questions

Sheila King sheila@thinkspot.net
Sat, 07 Jul 2001 16:34:51 -0700


On Sat, 7 Jul 2001 19:39:58 -0400 (EDT), Stephen Lastinger
<s.lastinger@computernetdesign.com>  wrote about [Tutor] a question
based on Sheila's Tkinter class defn questions:

:Just to see if I got this straight....Based on this formula:
:
:instance.method(args...) => becomes => class.method(instance, args...)

I can't comment on the above stuff, but...

:Frame.__init__(self, parent=None)
:
:calls the Frame superclass __init__ method by a (and i'm not sure i'm
:using the right term here) instance caller like:
:
:im_feeling_dufus_like=Frame(blah)
:
:and blah would be the argument passed to parent?

Yes, this is correct.

:I've got inheretance[sp.] and specialization down cold, but this
:....ugh
:
:and passing blah to parent...would that in turn be passed to the Frame
:__init__ method, and if so is it master, cnf, **kw, or none of the
:above...

It would pass blah to parent, and then in the Frame.__init__ method, it
is passed to master. self is the Frame instance, itself. master is the
parent. I'm not sure what cnf is, but **kw is (I believe) a dictionary
of all additional parameters not already specified by a particular
argument in the parameter list. In this way, you can pass an unlimited
number of parameters. In Tkinter, you may want to optionally specify a
number of configuration options. I suppose, they must get 
passed to **kw ?? (My newbie-ish sort of guess...)

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/

On Sat, 7 Jul 2001, Sheila King wrote:
[snip..]
>
> Here is an example from the book:
>
> ---------------page 305 quitter.py------------------------------
> #############################################
> # a quit button that verifies exit requests;
> # to reuse, attach an instance to other guis
> #############################################
>
> from Tkinter import *                          # get widget classes
> from tkMessageBox import askokcancel           # get canned std dialog
>
> class Quitter(Frame):                          # subclass our GUI
>     def __init__(self, parent=None):           # constructor method
>         Frame.__init__(self, parent)
>         self.pack()
>         widget = Button(self, text='Quit', command=self.quit)
>         widget.pack(expand=YES, fill=BOTH, side=LEFT)
>     def quit(self):
>         ans = askokcancel('Verify exit', "Really quit?")
>         if ans: Frame.quit(self)
>
> if __name__ == '__main__':  Quitter().mainloop()
> -----------------------------------------------------------------
> class Frame(Widget):
>     """Frame widget which may contain other widgets and can have a 3D
> border."""
>     def __init__(self, master=None, cnf={}, **kw):
>         """Construct a frame widget with the parent MASTER.
>
> #[much snipped]
> -----------------------------------------------------------------