I have a StringVar with Tkinter, I want to check that it is not empty. When I run the following condition, it is accepted while the variable is empty.
if self.var:
print(self.var)
The printed variable is PY_VAR1.
if self.var!= 'PY_VAR1':
print(self.var)
The printed variable is also PY_VAR1.
How to check that the value of self.var is not equal to PY_VAR1?
When I use get, it doesn't work either
if self.var.get():
print(self.var.get())
And when I change the value of self.var, with get (), nothing happens.
self.bouton = ttk.Button(self, text="print var", command=self.printvar)
def printvar(self):
print(self.var.get())
When I click on the button, the value of self.var is displayed and even when I change the value of self.var (), the new value is displayed. But I want to display the new value of self.var without clicking on the button. I want it to display dynamically.