[Tutor] Re: Tkinter and Animation

Jeremiah Rushton jeremiah.rushton at gmail.com
Wed Apr 27 18:35:47 CEST 2005


>> In a program that I'm writing in Tkinter, I wanted to know how to
>> animate objects. I have three buttons in the beginnig, all in the
>> center. I wanted to know how to, when the user clicks one of them,
>> make them small and move to a top corner and then have a text box
>> appear where they were.
>
>Do you actually want to _animate_ them (ie: have the buttons visually 
shrink and
>move across the screen), or do you just want them to vanish and appear in 
the
>new place?
>
>In Tkinter, placing an object on the screen (using grid or pack) is 
distinct
>from creating the object. You can use .grid_forget() or .pack_forget() to
>ungrid or unpack an object, so that it is not displayed, but it still 
exists.
>And/or you can just recall grid/pack with different arguments.
>
>eg:
>
>>>> from Tkinter import *
>>>> tk = Tk()
>>>> b = Button(tk, text='Make')
>>>> current = [0]
>>>> def make():
>... c = current[0]
>... Label(tk, text='Entry %d' % c).grid(row=c, column=0)
>... Entry(tk).grid(row=c, column=1)
>... b.grid(row=c+1, column=1)
>... current[0] = c + 1
>...
>>>> b.config(command=make)
>>>> b.grid(row=0, column=1)
>
>--
>John.

I wanted them to visually shrink and visually move to a corner on the frame. 
I did not know how to do it the way you explained, thanks for that. But is 
there any way to do it visually?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050427/e9dec92b/attachment.htm


More information about the Tutor mailing list