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.
1 Answer 1
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
ShroomBandit
4411 gold badge5 silver badges12 bronze badges
Sign up to request clarification or add additional context in comments.
8 Comments
Bryan Oakley
@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.
user1956027
@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
ShroomBandit
without more code I don't see anything in there that would crash the program except possibly quit() as mentioned before
user1956027
@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.
ShroomBandit
@user1956027 Yes, I posted that comment after reviewing the code in the link.
|
lang-py