Wayne Watson wrote: > The program below is derived from an example in Grayson for showing how > one might a dialog for entering passwords. The structure seems just like > the original, down to the use of self, Label and Entry plus . Yet the > print "here" statement produces: > here None <type 'NoneType'> > I'm missing something. The NoneType causes the print of the self.lat to > fail with get(). > > The original returns something from the corresponding body function, but > taking it out does nothing in either program. The original program is > posted above under "Modifying Grayson's Example 5_14". > > # Derived from Grayson 5_14.py > from Tkinter import * > from tkSimpleDialog import Dialog > import tkSimpleDialog > import tkMessageBox > #import Pmw > > class DialogPrototype(Dialog): > > def body(self, master): > self.title("Enter Site Data") > Label(master, text='Latitude:').grid(row=0, sticky=W) > self.lat=Entry(master, width=12).grid(row=0, column=1)
This is where you diverge from the Grayson example. What you're saying is that self.lat should be set to the result of Entry(...).grid(...) which is always None, presumably. What I think you want is self.lat to be a reference to the Entry widget itself. Try this, self.lat = Entry(master, width=12) self.lat.grid(row=0, column=1) > > Label(master, text='Longitude:').grid(row=0, column=2) > self.long=Entry(master, width=12).grid(row=0, column=3) ... and, self.long = Entry(master, width=12) self.long.grid(row=0, column=3) > print "here", self.long,type(self.long) > return > > def apply(self): > print "apply" > print self.lat.get() > print self.long.get() > > print "setting" > lat=1.0 > long=0.0 Is that the way you indented the above, really? I suppose it could be intentional, but probably not. > > root = Tk() > root.withdraw() > dialog = DialogPrototype(root) HTH, Marty _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor