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

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=0451a1742=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.04; 'root': 0.05; 'mouse': 0.07; 'sys': 0.07; 'tkinter': 0.07; 'callback': 0.09; 'identifier': 0.09; 'parameter': 0.09; 'subject:trying': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'subject: \n ': 0.16; 'subject:Tkinter': 0.16; 'subject:non': 0.16; 'subject:object': 0.16; 'subject:oriented': 0.16; 'subject:simple': 0.16; 'for?': 0.16; 'subject:] ': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'subject:problem': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'label': 0.30; 'jean': 0.31; 'skip:# 10': 0.33; 'but': 0.35; 'thanks': 0.36; 'url:org': 0.36; 'clear': 0.37; 'button': 0.38; 'thank': 0.38; 'called': 0.40; 'read': 0.60; 'event.': 0.60; 'tell': 0.60; 'you.': 0.62; 'information': 0.63; 'received:194': 0.64; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'url:htm': 0.73; 'disclose': 0.74; 'discovered': 0.83; 'click.': 0.84; 'standing': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.93,841,1378850400"; d="scan'208";a="2212177"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Fri, 6 Dec 2013 15:01:27 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Jean Dubois <jeandubois314@gmail.com>
In-Reply-To <b04cffb3-ad58-44c9-a441-13b8824f0c27@googlegroups.com>
Subject Re: [newbie] problem trying out simple non object oriented use of Tkinter
MIME-Version 1.0
X-Mailer Zimbra 7.2.4_GA_2900 (ZimbraWebClient - GC31 (Win)/7.2.4_GA_2900)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3648.1386338490.18130.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386338490 news.xs4all.nl 2912 [2001:888:2000:d::a6]:36302
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61148

Show key headers only | 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