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.
root.update()?select_folderis from a button that isn't created until you callselect_folder. Please try to create a complete minimal reproducible example - it's really hard to understand what you're asking when we only have a few lines of code. We definitely don't want your whole program, but we need more than what you've posted. If you're truly just asking how to check if a stringvar is empty, what you're doing will work.select_folder()after you have chosen a folder inside the callback called by menu action?