The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by pbfisher]

Two questions about the example on p.196
When I type win=Tk() a window pops up. Is that supposed to happen?
When I type the next line I get an error message. See below.

Python 2.0 (#8, Oct 16 2000, 17:27:5smilie [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.6 -- press F1 for help
>>> from Tkinter import *
>>> import sys
>>> win=Tk()
>>> button=Button(win,text='Goodbye',command=sys.exit)
Traceback (innermost last):
File "<pyshell#3>", line 1, in ?
button=Button(win,text='Goodbye',command=sys.exit)
File "c:python20liblib-tkTkinter.py", line 1819, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "c:python20liblib-tkTkinter.py", line 1758, in __init__
self.tk.call(
TclError: can't invoke "button" command: application has been destroyed
>>>

What does this mean? and how do I fix it?
Thanks for any help you can give. Just bought the book and find it very
useful so far, but I have a long way to go!!
import-bot (20211) [Avatar] Offline
#2
Re: Tcl
[Originally posted by zonja]

I did exactly as you did, with the only exception that,
following button = Button(win, text="Goodbye", command=sys.exit),
I added a line to position the button, like this:
button.grid(row=0, column=0),
and it worked like a charm. The only difference is, I am
running python 1.5.2. Works perfectly well. Best, elena

P.S. Actually, what I said above unleashes certain alarm
bells for me. It would be alarming if python were not
backward compatible for such a simple case as this one.
Or else, it is highly unstable depending on platform?
Hope not...

> Two questions about the example on p.196
> When I type win=Tk() a window pops up. Is that supposed to happen?
> When I type the next line I get an error message. See below.
>
> Python 2.0 (#8, Oct 16 2000, 17:27:5smilie [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.6 -- press F1 for help
> >>> from Tkinter import *
> >>> import sys
> >>> win=Tk()
> >>> button=Button(win,text='Goodbye',command=sys.exit)
> Traceback (innermost last):
> File "<pyshell#3>", line 1, in ?
> button=Button(win,text='Goodbye',command=sys.exit)
> File "c:python20liblib-tkTkinter.py", line 1819, in __init__
> Widget.__init__(self, master, 'button', cnf, kw)
> File "c:python20liblib-tkTkinter.py", line 1758, in __init__
> self.tk.call(
> TclError: can't invoke "button" command: application has been destroyed
> >>>
>
> What does this mean? and how do I fix it?
> Thanks for any help you can give. Just bought the book and find it very
> useful so far, but I have a long way to go!!
import-bot (20211) [Avatar] Offline
#3
Re: Tcl
[Originally posted by pbfisher]

Thanks for the answer, but I found out what I was doing
wrong. I closed the window that popped up when I entered
win=Tk()!!!It was in the way, but if I just drag it to a
position out of the way every thing works fine!!


> I did exactly as you did, with the only exception that,
> following button = Button(win, text="Goodbye", command=sys.exit),
> I added a line to position the button, like this:
> button.grid(row=0, column=0),
> and it worked like a charm. The only difference is, I am
> running python 1.5.2. Works perfectly well. Best, elena
>
> P.S. Actually, what I said above unleashes certain alarm
> bells for me. It would be alarming if python were not
> backward compatible for such a simple case as this one.
> Or else, it is highly unstable depending on platform?
> Hope not...
>
> > Two questions about the example on p.196
> > When I type win=Tk() a window pops up. Is that supposed to happen?
> > When I type the next line I get an error message. See below.
> >
> > Python 2.0 (#8, Oct 16 2000, 17:27:5smilie [MSC 32 bit (Intel)] on win32
> > Type "copyright", "credits" or "license" for more information.
> > IDLE 0.6 -- press F1 for help
> > >>> from Tkinter import *
> > >>> import sys
> > >>> win=Tk()
> > >>> button=Button(win,text='Goodbye',command=sys.exit)
> > Traceback (innermost last):
> > File "<pyshell#3>", line 1, in ?
> > button=Button(win,text='Goodbye',command=sys.exit)
> > File "c:python20liblib-tkTkinter.py", line 1819, in __init__
> > Widget.__init__(self, master, 'button', cnf, kw)
> > File "c:python20liblib-tkTkinter.py", line 1758, in __init__
> > self.tk.call(
> > TclError: can't invoke "button" command: application has been destroyed
> > >>>
> >
> > What does this mean? and how do I fix it?
> > Thanks for any help you can give. Just bought the book and find it very
> > useful so far, but I have a long way to go!!