I am using a StringVar to update a label on a GUI.
I am using the set method to update the value, but the text never shows up when the application is run.
I am able use the get method (the final print statement, as seen below) and see that the value that has been passed into it, but it still doesn't show up on my window. I am using a mac with Spyder.
class Application(tk.Frame):
def __init__(self, bud, master=None):
super().__init__(master)
self.bud = bud
self.master = master
self.pack()
self.bud.update_all()
self.r = 1
self.create_widgets()
def create_widgets()
trans = [tk.StringVar() for c in self.bud.categories]
for i, c in enumerate(self.bud.categories):
tk.Label(self, text = c.name, anchor = "w").grid(row = self.r, column = 0)
tk.Label(self, textvariable = trans[i],fg = "black").grid(row = self.r, column = 1)
trans[i].set("Hello")
self.r +=1
print(trans[i].get())
This section is run outside the class in the main script
root = tk.Tk()
app = Application(bud, master = root)
app.mainloop()