Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25091
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'root': 0.04; '__name__': 0.07; 'prefix': 0.07; 'tkinter': 0.07; 'versions.': 0.07; 'event):': 0.09; 'expected.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'def': 0.10; '(the': 0.15; 'properly': 0.15; "'__main__':": 0.16; 'constants': 0.16; 'message-id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'record,': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'copied': 0.17; 'jan': 0.18; 'code,': 0.18; 'import': 0.21; 'runs': 0.22; 'example': 0.23; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'skip:e 30': 0.27; 'skip:e 40': 0.27; 'header:X-Complaints-To:1': 0.28; 'post': 0.28; '(maybe': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; "skip:' 10": 0.30; 'window': 0.30; 'code': 0.31; 'problem.': 0.32; 'johnson': 0.32; "skip:' 20": 0.32; 'could': 0.32; 'idle': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'posting': 0.35; 'something': 0.35; 'add': 0.36; 'received:org': 0.36; 'but': 0.36; "i'll": 0.36; 'should': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'think': 0.40; 'remove': 0.61; 'back': 0.62; 'details': 0.63; 'more': 0.63; 'jul': 0.65; 'fields,': 0.84; 'received:fios.verizon.net': 0.84; 'subject:gets': 0.84; 'rick': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Tkinter.event.widget: handler gets name instead of widget. |
| Date | Mon, 09 Jul 2012 15:45:38 -0400 |
| References | <1341782353.2041.136.camel@hatchbox-one> <mailman.1933.1341813557.4697.python-list@python.org> <e903a18d-a348-4ba3-8b0c-2b51bca7dbd6@l32g2000yqc.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-74-109-121-73.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 |
| In-Reply-To | <e903a18d-a348-4ba3-8b0c-2b51bca7dbd6@l32g2000yqc.googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1953.1341863177.4697.python-list@python.org> (permalink) |
| Lines | 78 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1341863177 news.xs4all.nl 6980 [2001:888:2000:d::a6]:36806 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25091 |
Show key headers only | View raw
On 7/9/2012 1:49 PM, Rick Johnson wrote:
> On Jul 9, 12:58 am, Terry Reedy <tjre...@udel.edu> wrote:
>> When posting problem code, you should post a minimal, self-contained
>> example that people can try on other systems and versions. Can you
>> create the problem with one record, which you could give, and one
>> binding? Do you need 4 fields, or would 1 'work'?
>
> I'll firmly back that sentiment. Fredric, if you cannot get the
> following simple code events to work properly, then how do you think
> you can get events working properly on something more complex?
>
> ## START CODE ARTISTRY ##
> import Tkinter as tk
> from Tkconstants import *
>
> class MyFrame(tk.Frame):
> def __init__(self, master, **kw):
> tk.Frame.__init__(self, master, **kw)
> self.bind('<Enter>', self.evtMouseEnter)
> self.bind('<Leave>', self.evtMouseLeave)
> self.bind('<Button-1>', self.evtButtonOneClick)
>
> def evtMouseEnter(self, event):
> event.widget.config(bg='magenta')
>
> def evtMouseLeave(self, event):
> event.widget.config(bg='SystemButtonFace')
>
> def evtButtonOneClick(self, event):
> event.widget.config(bg='green')
>
> if __name__ == '__main__':
> root = tk.Tk()
> for x in range(10):
> f = MyFrame(root, height=20, bd=1, relief=SOLID)
> f.pack(fill=X, expand=YES, padx=5, pady=5)
> root.mainloop()
> ## END CODE ARTISTRY ##
I copied and pasted this self-contained code into a 3.3 Idle edit window
and lightly edited for 3.x. Change 'Tkinter' to 'tkinter', remove
tkconstants import and prefix constants with 'tk.'. (The alternative:
change 'tkconstants' to 'tkinter.constants', but I prefer prefixes). It
runs as expected.
import tkinter as tk
class MyFrame(tk.Frame):
def __init__(self, master, **kw):
tk.Frame.__init__(self, master, **kw)
self.bind('<Enter>', self.evtMouseEnter)
self.bind('<Leave>', self.evtMouseLeave)
self.bind('<Button-1>', self.evtButtonOneClick)
def evtMouseEnter(self, event):
event.widget.config(bg='magenta')
def evtMouseLeave(self, event):
event.widget.config(bg='SystemButtonFace')
def evtButtonOneClick(self, event):
event.widget.config(bg='green')
if __name__ == '__main__':
root = tk.Tk()
for x in range(10):
f = MyFrame(root, height=20, bd=1, relief=tk.SOLID)
f.pack(fill=tk.X, expand=tk.YES, padx=5, pady=5)
root.mainloop()
Add details and data (maybe less than 10 records) until you get what you
want or recreate problem.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Tkinter.event.widget: handler gets name instead of widget. Terry Reedy <tjreedy@udel.edu> - 2012-07-09 01:58 -0400
Re: Tkinter.event.widget: handler gets name instead of widget. Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-09 10:49 -0700
Re: Tkinter.event.widget: handler gets name instead of widget. Terry Reedy <tjreedy@udel.edu> - 2012-07-09 15:45 -0400
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch <anthra.norell@bluewin.ch> - 2012-07-09 22:47 +0200
Re: Tkinter.event.widget: handler gets name instead of widget. Chris Angelico <rosuav@gmail.com> - 2012-07-10 08:23 +1000
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch <anthra.norell@bluewin.ch> - 2012-07-10 12:03 +0200
Re: Tkinter.event.widget: handler gets name instead of widget. Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-10 15:11 -0700
Re: Tkinter.event.widget: handler gets name instead of widget. Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-10 18:06 -0700
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch <anthra.norell@bluewin.ch> - 2012-07-11 09:59 +0200
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch <anthra.norell@bluewin.ch> - 2012-07-12 20:53 +0200
Re: Tkinter.event.widget: handler gets name instead of widget. rantingrickjohnson@gmail.com - 2012-07-14 20:10 -0700
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch <anthra.norell@bluewin.ch> - 2012-07-16 12:32 +0200
Re: Tkinter.event.widget: handler gets name instead of widget. rantingrickjohnson@gmail.com - 2012-07-14 20:10 -0700
Re: Tkinter.event.widget: handler gets name instead of widget. Peter Otten <__peter__@web.de> - 2012-07-13 09:26 +0200
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch <anthra.norell@bluewin.ch> - 2012-07-13 22:24 +0200
Re: Tkinter.event.widget: handler gets name instead of widget. Terry Reedy <tjreedy@udel.edu> - 2012-07-13 19:23 -0400
Re: Tkinter.event.widget: handler gets name instead of widget. Peter Otten <__peter__@web.de> - 2012-07-14 09:47 +0200
csiph-web