[newbie] problem trying out simple non object oriented use of Tkinter

Jean-Michel Pichavant jeanmichel at sequans.com
Fri Dec 6 13:33:05 CET 2013


----- Original Message -----
> I'm trying out Tkinter with the (non object oriented) code fragment
> below:
> It works partially as I expected, but I thought that pressing "1"
> would
> cause the program to quit, however I get this message:
> TypeError: quit() takes no arguments (1 given), I tried changing quit
> to quit()
> but that makes things even worse. So my question: can anyone here
> help me
> debug this?
> 
> #!/usr/bin/env python
> import Tkinter as tk
> def quit():
>     sys.exit()
> root = tk.Tk()
> label = tk.Label(root, text="Hello, world")
> label.pack()
> label.bind("<1>", quit)
> root.mainloop()
> 
> p.s. I like the code not object orientated
> --
> https://mail.python.org/mailman/listinfo/python-list
> 

the engine is probably passing an argument to your quit callback method.

try  

def quit(param):
  sys.exit(str(param))

You probably don't even care about the parameter:

def quit(param):
  sys.exit()

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list