Hi,
I don’t think it’s possible to do this (change the Background Color -bg- of a Root Window -root- over time), but it is possible to change the Background Color of a TK Object, which is an entirely different proposition. The reason being, that (so far as I know, from my experience) the only way to have said change take effect, once an object has been created and drawn, using whatever geometry manager you choose, is to .destroy()
said object, then recreate it with a different bg
attribute. For very obvious reasons, that can’t be done with the root
window.
Maybe this function (from one of my apps) will demonstrate.
def verify():
global publishedText
rt = resultText.get('1.0', tk.END)
rt = rt.strip()
print('Result:',rt)
pt = publishedText.get('1.0', tk.END)
pt = pt.strip()
if rt and pt != '\n':
if rt == pt:
publishedText.destroy()
publishedText = tk.Text(publishedLF,
width=63,
height=2,
bg='green',
fg=textColor,
font=(appFont)
)
publishedText.insert('1.0', pt)
publishedText.place(relx=0.01, rely=0.01)
else:
publishedText.destroy()
publishedText = tk.Text(publishedLF,
width=63,
height=2,
bg='red',
fg=textColor,
font=(appFont)
)
publishedText.insert('1.0', pt)
publishedText.place(relx=0.01, rely=0.01)
I’ve never tried to create a Gradient Animation and as such I can’t answer that part of your question.
edit to add…
Thinking some more about the Gradient Animation question, at least in theory, this could be done with a multiple create and destroy operation, controlled with a program loop, successively changing the bg
attribute with each loop.
edit (again) to complete this train of thought…
Given that you’d need at least 15 f.p.s to get an acceptable animation, I don’t think that the above solution is practical, but it may be worth your time to try it, if you’ve nothing to lose.