Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/customtkinter/windows/widgets/ctk_button.py", line 554, in _clicked
self._command()
floatVar = float(self.Answer_Text_Variable.get())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: ''
The method Mark() is inside a class called Question however when the class is instantiated in another class(QuestionSet) the tkinter entry box always returns a blank string rather than a string of the numbers entered.
When the method mark()is called through an instance by itself it works completely fine, the error only occurs when it is called from within another class.
Any help is appreciated. Cheers
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/tkinter/__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/customtkinter/windows/widgets/ctk_button.py", line 554, in _clicked
self._command()
floatVar = float(self.Answer_Text_Variable.get())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: ''
def Mark(self): floatVar = float(self.Answer_Text_Variable.get()) print(self.Answer_Text_Variable.get()) if floatVar == self.Correct_Answer: self.Question_Answer_entry.configure(fg_color = "#90EE90") self.Answer_message_Label.configure(text = 'Correct!') self.Answer_message_Label.place(relx = 0.6, rely = 0.66) self.Correct = 1 else: self.Question_Answer_entry.configure(fg_color = "#FF3131") self.Answer_message_Label.place(relx = 0.6, rely = 0.66) print(f'You put {self.Answer_Text_Variable.get()}') print(self.Correct_Answer)Below is it being called in another class. Moment easy inherits Question
if self.ListOfQuestions[i] == 'Moments': realQuestion = MomentEasy() realQuestion.Generate() realQuestion.ShowQuestion()The method ShowQuestion() calls mark when run
self.Mark_button = Ctk.CTkButton(self.QuestionWindow, text = 'Mark', command = self.Mark)if i ran the exact same code outside a class it works everytime perfectly
The method Mark() is inside a class called Question however when the class is instantiated in another class(QuestionSet) the tkinter entry box always returns a blank string rather than a string of the numbers entered.
When the method mark()is called through an instance by itself it works completely fine, the error only occurs when it is called from within another class.
Any help is appreciated. Cheers