1

I'm trying to figure out an error I get that is related to comparison of function output with an integer:

This is the code:

def qExit():
    tkinter.messagebox.askyesno('Quit system', 'Do you want to quit?')

    if qExit>0:
        root.destroy()
        return

This is the error I get whenever I press press the yes button in the message box:

    if qExit>0:
TypeError: '>' not supported between instances of 'function' and 'int'

Thanks for the help!

RB

1
  • What you are intended to do with qExit>0? Commented Dec 26, 2018 at 5:19

2 Answers 2

1

Yes, because the response you are receiving will be in string format and you are not handling that response.

Here in your code, you are not assigning the response to any variable and using function name directly in condition validation. You are literally doing "function" and "int" comparison.

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

Comments

0

See answer below:

def qExit():
    MsgBox = tkinter.messagebox.askyesno('Quit system', 'Do you want to quit?')

    if MsgBox > 0:
        root.destroy()
    else:
        tkinter.messagebox.showinfo('Return', 'You will now return to the application screen')

Comments

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.