user9185511
user9185511

Reputation: 814

Python tkinter message box

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

Upvotes: 1

Views: 525

Answers (2)

user9185511
user9185511

Reputation: 814

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

Upvotes: 0

Raja G
Raja G

Reputation: 6633

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.

Upvotes: 1

Related Questions