2

Im making a GUI and want to add an exit button to close the window. The only problem is, when i add a button with the following code:

root = Tk()

Exit = Button(root, text = "Quit", command = root.quit()).grid(row = 6, column = 1)

the GUI window crashes. Im running windows 7 and Python 3.2.

asked Jan 7, 2013 at 19:30

1 Answer 1

3

Try this:

root = Tk()
Exit = Button(root, text = "Quit", command = root.quit).grid(row = 6, column = 1)

in the root.quit() I took out the parenthesis. See if that solves the problem

answered Jan 7, 2013 at 19:35
Sign up to request clarification or add additional context in comments.

8 Comments

@user1956027: I think you must be mistaken. This definitely is the problem with the code in your question. If the same thing happened then there is more code you aren't showing us. Most likely you replicated the problem elsewhere, such as creating a menu.
@Bryan Oakley, here is a pastbin for a bit more of the code. Its the only part that I would think would cause a problem, everything before is just imports and functions ect. pastebin.com/jpL04jFz
without more code I don't see anything in there that would crash the program except possibly quit() as mentioned before
@Joseph Owens Have a look at that link I posted, it has some more code that may have the reason it crashes, though im not sure my self.
@user1956027 Yes, I posted that comment after reviewing the code in the link.
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.