9/12/2023 0 Comments Tkinter winfo exists![]() I don't have code here to test this with, so you should also try to define self.ErrorLabel=None at _init_ too if first method doesn't work. This way it checks if the widget is made and if the widget is not made, then ignores. Then your delete_error() would be: def delete_error(self): The python variable may continue to exist after you have destroyed the widget and in this case. What you could do is set ErrorLabel to be None and then check if it is None or not when calling delete_error(), if it is None then ignore, else find its existence. winfoexists returns true only if the Tk widget has a window. ![]() Self.ErrorLabel = tk.Label(ame2, text="Error: check ✔️ the correct answer ", fg='white', bg='red') Self.ErrorLabel = tk.Label(ame2, text="Error: Fill all the blanks !", fg='white', bg='red') This is how it gets assigned: def raise_errors(self, flag): That's why I need to check the existence of it when using grid_forget() So, Im just making a silly program with TKinter to simulate the DVD bouncing logo, which works, but doesnt change the colors (in this case I have 4 different images. winfoexists () is supposed to return 1 or 0 depending on the existence of a widget when I use. At this point Im not getting an error, its just not working at all. ( the assignment of this variable depends if there is an error in input in the program so it doesn't always assign it, Ive seen almost every post about this issue and nothing solved it. I don't understand why I get 'not defined' because I'm checking the existence of a object, so it doesn't have to be defined? ![]() making '_exists()' into a variable and putting that in if statement.If _exists() = 1: # even with 'self.' removed same error occurs This is how I called the function: def delete_error(self): winfo_exists(), to check if a widget exists then I get the error: (Not defined) name 'ErrorLabel' not defined winfo_exists() is supposed to return 1 or 0 depending on the existence of a widget 1.winfoexists () is supposed to return 1 or 0 depending on the existence of a widget.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |