I was trying to update the text of a label in tkinter with values stored in a list when I noticed that tkinter seemingly adds '{}' to the label text when the passed list element is empty.
import tkinter as tk
root = tk.Tk()
list1 = [["someText"], []]
tk.Label(root, text=list1).pack()
root.mainloop()
Can someone explain where the curly brackets come from and why they are added? Your help is appreciated.
CodePudding user response:
Python's tkinter library is an interface for Tcl/Tk. As part of this interfacing python has to decide how to interpret the values that you pass it. If you pass it a value where str(value) is falsey then it replaces it with {}, as shown in this part of the source code.
