Ah, very subtle. Thanks. That worked, but I got shelled by: Program output (22, 33 are what I entered): apply 22 33 Traceback (most recent call last): File "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/sentuser/NewSentDlg.py", line 35, in <module> dialog = DialogPrototype(root) File "C:\Python25\lib\lib-tk\tkSimpleDialog.py", line 69, in __init__ self.wait_visibility() # window needs to be visible for the grab File "C:\Python25\lib\lib-tk\Tkinter.py", line 415, in wait_visibility self.tk.call('tkwait', 'visibility', window._w) TclError: window ".60529560" was deleted before its visibility changed Martin Walsh wrote: 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.0Is 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 --
Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain |
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor