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

Jean-Michel Pichavant jeanmichel at sequans.com
Fri Dec 6 09:01:27 EST 2013


> I tried out your suggestions and discovered that I had the line
> import sys to the program. So you can see below what I came up with.
> It works but it's not all clear to me. Can you tell me what
> "label.bind("<1>", quit)" is standing for? What's the <1> meaning?
> 
> 
> 
> #!/usr/bin/env python
> import Tkinter as tk
> import sys
> #underscore is necessary in the following line
> def quit(_):
>     sys.exit()
> root = tk.Tk()
> label = tk.Label(root, text="Click mouse here to quit")
> label.pack()
> label.bind("<1>", quit)
> root.mainloop()
> 
> thanks
> jean

The best thing to do would be to read
http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm


"<1>" is the identifier for you mouse button 1.
quit is the callback called by the label upon receiving the event mouse1 click.

Note that the parameter given to your quit callback is the event.

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