Marc 'BlackJack' Rintsch wrote:
On Sun, 08 Mar 2009 22:20:09 -0700, W. eWatson wrote:
You didn't answer my question why entry is necessary at all. The
original author thought it was necessary to return entry. I'll give you
a peek at a segment of the code I'm working with here:
class Enter_Data_Dialog(tkSimpleDialog.Dialog):
def __init__(self, parent, sdict):
self.sdict = sdict
tkSimpleDialog.Dialog.__init__(self, parent)
def body(self,master):
self.title("Set a Number Entry Dialog")
Label( master, text="Number ").grid(row=0, sticky=W)
self.anumberVar = StringVar()
entry = Entry(master, width=10,
textvariable=self.anumberVar).grid(row=0,
column=1)
self.anumberVar.set( "%d" % self.sdict["anumber"] )
return entry
`entry` is unnecessary here. But that was not obvious from your previous
example, as you trimmed the code. Now it is clear that `entry` is always
`None` because that's what `grid()` returns.
But according to the docs this method should return the widget, that
should get the focus, so maybe the author really wanted to return the
`Entry` instance here, instead of `None`.
Ciao,
Marc 'BlackJack' Rintsch
He's got to return something, because he uses it upon return, as here:
def Set_Enter_Data(self):
sdict = {}
sdict[ "ok" ] = False
sdict[ "anumber" ] = self.anumber
dialog = Enter_Data_Dialog( self.master, sdict ) <--- returning
self.Focus()
print "Howdy, set data. Number is:", dialog.anumberVar.get()
print "dict:", dialog.sdict
if not dialog.sdict["ok"]:
return
try:
self.anumber = int(eval(dialog.anumberVar.get()))
print "OK"
except:
print "Not OK"
pass
print "self.anumber:", self.anumber
--
W. eWatson
(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
Web Page: <www.speckledwithstars.net/>
--
http://mail.python.org/mailman/listinfo/python-list