1

So this is the code python doesn't seem to be too happy with me about:

def checkAnswer(self, clickedButton):
            self.valueOne = self.itemOne[self.component]
            self.valueTwo = self.itemTwo[self.component]

            if clickedButton == 'left':
                if self.valueOne >= self.valueTwo:
                    tkinter.messagebox.showinfo('Smart Cookie!', 'That\'s correct!')

                else:
                    tkinter.messagebox.showerror('Oh No!', 'That\'s incorrect!')

            elif clickedButton == 'middle':
                if self.valueOne - (self.valueOne * 0.1) <= self.valueTwo <= self.valueOne + (self.valueOne * 0.1) and self.valueTwo - (itemTwoComp * 0.1) <= self.valueTwo <= self.valueTwo + (self.valueTwo * 0.1):
                    tkinter.messagebox.showinfo('Smart Cookie!', 'That\'s correct!')

                else:
                    tkinter.messagebox.showerror('Oh No!', 'That\'s incorrect!')

            elif clickedButton == 'right':
                if self.valueTwo >= self.valueOne:
                    tkinter.messagebox.showinfo('Smart Cookie!', 'That\'s correct!')

                else:
                    tkinter.messagebox.showerror('Oh No!', 'That\'s incorrect!')


            showQuestion()


        tkinter.mainloop()
        showQuestion()

gui = ProgramGUI()

and this is the error I'm receiving:

Traceback (most recent call last):
  File "C:\Assignments\Assignment 2\FIddle.py", line 101, in <module>
    gui = ProgramGUI()
  File "C:\Assignments\Assignment 2\FIddle.py", line 99, in __init__
    showQuestion()
  File "C:\Assignments\Assignment 2\FIddle.py", line 60, in showQuestion
    self.lab11.configure(text = self.itemList[0]['Name'])
  File "C:\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 1330, in configure
    return self._configure('configure', cnf, kw)
  File "C:\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 1321, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name ".2531617022640.2531617023144"

I'm not sure why I'm receiving this error at all, would very much appreciate it if anyone could identify the problem.

1 Answer 1

1

showQuestion() is trying to modify a widget, but it is being called after the root window has been destroyed (eg: after mainloop() returns, which only happens when the root window has been destroyed). When the root window is destroyed, all other widgets are also destroyed.

Sign up to request clarification or add additional context in comments.

1 Comment

You're an absolute star, Bryan, thank-you. That's gone and fixed it and sorted out a few more issues I was having!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.