1
votes

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

2
What you are intended to do with qExit>0? - Abdul Niyas P M

2 Answers

1
votes

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.

0
votes

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')