Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #61148

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

Date 2013-12-06 15:01 +0100
From Jean-Michel Pichavant <jeanmichel@sequans.com>
Subject Re: [newbie] problem trying out simple non object oriented use of Tkinter
Newsgroups comp.lang.python
Message-ID <mailman.3648.1386338490.18130.python-list@python.org> (permalink)

Show all headers | View raw


> 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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [newbie] problem trying out simple non object oriented use of Tkinter Jean-Michel Pichavant <jeanmichel@sequans.com> - 2013-12-06 15:01 +0100

csiph-web