Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103423
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: exit from Tkinter mainloop Python 2.7 |
| Date | 2016-02-23 23:45 +0100 |
| Organization | None |
| Message-ID | <mailman.82.1456267517.20994.python-list@python.org> (permalink) |
| References | <56e451a3-01f7-4883-b4db-c3a6a10729a9@googlegroups.com> <naimao$327$1@dont-email.me> |
Christian Gollwitzer wrote:
> Am 23.02.16 um 22:39 schrieb kevind0718@gmail.com:
>> from Tkinter import *
>>
>> def butContinue():
>> root1.destroy()
>> [...]
>> entryName = Entry(root1).grid(row=1, column=1, pady=5)
>> [...]
>> butGo = Button(root1, text=" Continue " , command=butContinue
>> ).grid(row=3, column=1, sticky=W, pady=10)
>>
>> root1.mainloop()
>>
>> print entryName.get("1.0", "end-1c" )
>
>> When I click on butGo I get the error below.
>> So is this some sort of scope error?
>> why does entryName not exist for me to grab it's value?
>
> You call destroy() on the root window of Tk. If you destroy a window,
> that will destroy all of it's children. Therefore by deleting the root
> window, also the entryName widget was deleted. You need to export the
> values before you close the window, i.e. in the butContinue() function.
Even when you follow this advice, entryName was set to None by the line
>> entryName = Entry(root1).grid(row=1, column=1, pady=5)
as grid() always returns None. You need two steps
entryName = Entry(root1)
entryName.grid(row=1, column=1, pady=5)
Also,
>> print entryName.get("1.0", "end-1c" )
I believe that the Entry widget's get() method doesn't take any arguments.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
exit from Tkinter mainloop Python 2.7 kevind0718@gmail.com - 2016-02-23 13:39 -0800
Re: exit from Tkinter mainloop Python 2.7 Christian Gollwitzer <auriocus@gmx.de> - 2016-02-23 23:29 +0100
Re: exit from Tkinter mainloop Python 2.7 Peter Otten <__peter__@web.de> - 2016-02-23 23:45 +0100
Re: exit from Tkinter mainloop Python 2.7 Christian Gollwitzer <auriocus@gmx.de> - 2016-02-23 23:33 +0100
Re: exit from Tkinter mainloop Python 2.7 kevind0718@gmail.com - 2016-03-04 13:50 -0800
Re: exit from Tkinter mainloop Python 2.7 Peter Otten <__peter__@web.de> - 2016-03-04 23:28 +0100
Re: exit from Tkinter mainloop Python 2.7 Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-09 11:17 -0800
Re: exit from Tkinter mainloop Python 2.7 Dave Farrance <df@see.replyto.invalid> - 2016-02-24 09:34 +0000
csiph-web