[Tutor] problem with msg widget & button
Cranky Frankie
cranky.frankie at gmail.com
Tue Nov 29 16:54:49 CET 2011
Peter Otten <__peter__ at web.de> wrote:
snip
<<Hm, your description doesn't match with the code you posted which only
creates one Message.>>
What I meant to say was, yes, I only want one message object, but I
want that same object to be updated each time the next quote button is
pressed.
<<Also you still initialize the command parameter with the function result
Button(..., command=f()) # wrong
instead of the function itself
Button(..., command=f) # correct.>>
snip again
OK, I think I tried it several ways and couldn't get any of them to
work, but I tried your version and the button now works! My only
question is this line, which is what I was missing:
def display_quote():
msg_widget["text"] = choose_quote()
Isn't msg_widget an object, like everything else in Python. If so, why is it not
def display_quote():
msg_widget.text = choose_quote()
That is one of the things I tried. I don't understand why the ["test"]
pair works above.
Now my only problem is the msg_widget box resizing. I'm using the
.pack frame manager like the examples I've been reading say. I know
there's a grid manager as well. I'll have to try that. All I want is
the msg_widget to display the same size each time, no matter what size
string is in it.
Thanks Peter!
--
Frank L. "Cranky Frankie" Palmeri
Risible Riding Raconteur & Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
More information about the Tutor
mailing list