[Tutor] Re: Re: Re: Tkinter and Animation
Jeremiah Rushton
jeremiah.rushton at gmail.com
Thu Apr 28 04:31:06 CEST 2005
>>
>> 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?
>>
>
>I guess so, if you use the "place" geometry manager. With place() you can
determine
>things like x- and y-coordinates on the parent widget and relative width /
height,
>so if you start a loop that moves the button 2 pixels up and one pixel to
the left
>every 50ms for example it might come close to the kind of animation you
want.
>It's probably tricky, but I think it's possible.
>
>Best regards
>
>Michael
I tried your idea and it doesn't animate it. I made a for loop and told it
to mover 1 pixel downward every .3 seconds for 25 times. It just waits till
the for loop is completed and then displays the result of the loop ending. I
also tried it without the for loop by writing each one of the steps out
repetively and I had the same result. The only thing that has kind of got
close to the visual is that I wrote a program that everytime the user
clicked the button it moved down one pixel, but I want it to move 100
pixels, one by one, with only one click from the user. Here's the code that
I wrote:
from Tkinter import *
from time import sleep
class Main:
def __init__(self,master):
button = Button(master,text='button')
button.place(x=1,y=1)
y=3
for x in range(1,25):
sleep(.3)
button.place_forget()
button.place(x=1,y=y)
y+=2
root = Tk()
Main(root)
root.title('test')
root.mainloop()
Thanks for all the help so far.
Jeremiah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050427/aff662d0/attachment.html
More information about the Tutor
mailing list