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


Groups > comp.lang.python > #61148 > unrolled thread

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

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2013-12-06 15:01 +0100
Last post2013-12-06 15:01 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

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

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2013-12-06 15:01 +0100
SubjectRe: [newbie] problem trying out simple non object oriented use of Tkinter
Message-ID<mailman.3648.1386338490.18130.python-list@python.org>
> 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web