Advertisement
here2share

# Tk_text_ani.py

Aug 5th, 2020 (edited)
1,214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. # Tk_text_ani.py
  2.  
  3. import Tkinter as tki
  4.  
  5. def scroll_text(s, how_many):
  6.     return s[how_many:] + s[:how_many]
  7.  
  8. direction = 1
  9. tk = tki.Tk()
  10. var = tki.Variable(tk)
  11.  
  12. def mouse_handler(point):
  13.     global direction
  14.     direction *= -1
  15.  
  16. def timer_handler():
  17.     var.set(scroll_text(var.get(),direction))
  18.     tk.after(125, timer_handler)
  19.  
  20. var.set('Hello, World! ..... Left-Click To Reverse ..... ')
  21. tki.Label(tk, textvariable=var).pack()
  22. tk.bind("<Button-1>", mouse_handler)
  23. tk.after(125, timer_handler)
  24. tk.title('Python Text Animation')
  25. tki.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement