This question made me wonder, what is exactly going on in the code below?
import tkinter as tk
class MyDot():
def __str__(self):
return "."
if __name__ == '__main__':
root = tk.Tk()
my_dot = MyDot()
tk.Entry(root, textvariable=root).pack()
tk.Label(root, textvariable=my_dot).pack()
tk.Button(root, textvariable=".").pack()
root.mainloop()
Why is having identical str(object)
s, as textvariable
option to widgets make their texts synchronized?