python - How do you make an animation with the title of a Tkinter window? -
this bit of eccentric question, answer.
all want make animation title of window, mean deleting each letter of title until it's blank. example of code in question.
def clearcommand(): letter in the_window.title(): the_window.title(the_window.title()[:len(the_window.title())-1])
i hoping code – when called button it's attached – delete single letter off end until title cleared.
the irritating part doesn't break code in question, seems update title once 'clearcommand' function ends.
is there way force window update i'm overseeing, or going wrong way?
example code if want test out:
from tkinter import * window = tk() window.title('this title contains guff.') def clearcommand(): letter in window.title(): window.title(window.title()[:len(window.title())-1]) clearbutton = button(window,text = 'clear title',command = clearcommand) clearbutton.pack(padx = 100) window.mainloop()
do other animation in tkinter: after
:
def clearcommand(): title = the_window.title()[:-1] the_window.title(title) if len(title) > 0: the_window.after(1000, clearcommand)
Comments
Post a Comment