[Tutor] Tkinter class member question

Michael P. Reilly arcege@speakeasy.net
Sun, 21 Oct 2001 18:16:23 -0400

On Sun, Oct 21, 2001 at 11:27:29PM +0200, Sharriff Aina wrote:
> I=B4m still trying to know how to encompass my tkinter widgets and scio=
ts in classes.
> Given:
> #### code start
> class Mydialog:
> ....def _init_(self, master):
> ........self.top=3DTkinter.Toplevel(master)
> ........self.name=3DTkinter.StringVar()
> ........entry =3DTkinter.Entry(self.top, textvariable=3Dself.name)## wh=
> ##### code snippet end
> why does the creation of the Entry widget start with "entry =3D" instea=
d of "self.entry" ? I thought all class variables have to start with self=
? Furthermore, is it wise to write global functions or to embed the funct=
ions in the widgets of the classes calling the functions?

The reason is probably because the data that is required is the contents
of the string Tkinter variable.  Unless there is a need for the program
to manipulate the widget (not the contents of the variable) after its
creation, there is no need to keep the reference.


| Michael P. Reilly                | arcege@speakeasy.net              |