Title: Signature.html
Good to hear there's nothing deeper in terms of some Python OOP
feature.
Thanks the global tips.
I think I'll be replacing some that sdict code, so that it's less
dependent upon hard coding the "user" variables.
Of course, it took me a lot longer than 2 minutes to put that together.
:-)
Alan Gauld wrote:
"Wayne Watson" <sierra_mtnv...@sbcglobal.net>
wrote
The question here is how is sdict being used
here in terms
of its need within the GUI? Probably if I had written the
program from scratch, I would have made all these
variables global to Sentinel_GUI.
Most programmers try to avoid global variables as a
general principle. In this case the programmer has
opted for a dict and is then able to pass the values
around with a single variable, as in:
def DisplaySettings(self):
print "OSett self = ", self, "type =", type(self)
<<---debug code
sdict = {} <<-------- local sdict
sdict[ "ok" ] = False <<---- ok
... more sdict ...
dialog = DisplaySettingsDialog( self.master, sdict )
class
DisplaySettingsDialog(tkSimpleDialog.Dialog):
def __init__(self, parent, sdict):
self.sdict = sdict <<-------
tkSimpleDialog.Dialog.__init__(self, parent)
You could use globals if both classes were in the samemodule,
or import the module wherever they values were needed. But
by keeping the values in a dict and keeping the dict as a
class variable the programmer potentially has more control
over access.
Thats the only reason I can see for it - after all of 2 minutes
reading the code :-)...
--
Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
Shhhh, quiet. I'm thinking about filling this space.
Web Page: <www.speckledwithstars.net/>
|
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor