Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'subject:bug': 0.05; 'tkinter': 0.07; 'desired,': 0.09; 'friday,': 0.09; 'inserted': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'unexpected': 0.09; 'def': 0.10; 'programmer': 0.11; 'assume': 0.11; 'suggest': 0.11; 'aug': 0.13; '"break"': 0.16; 'inputs': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'subject:Entry': 0.16; 'subject:Tkinter': 0.16; 'wrote:': 0.17; 'widget': 0.17; 'accepting': 0.18; 'url:edu': 0.18; 'input': 0.18; '(not': 0.20; 'sort': 0.21; 'all,': 0.21; 'import': 0.21; 'supposed': 0.21; 'event,': 0.22; "i'd": 0.22; 'insert': 0.23; "haven't": 0.23; "i've": 0.23; 'random': 0.24; 'header:User-Agent:1': 0.26; 'prevent': 0.27; 'interface': 0.27; 'header:X-Complaints-To:1': 0.28; 'handled': 0.29; 'probably': 0.29; 'becomes': 0.30; 'fri,': 0.30; 'web.': 0.30; 'code': 0.31; 'could': 0.32; 'print': 0.32; 'cancel': 0.33; 'docs': 0.33; 'to:addr:python-list': 0.33; 'entry': 0.33; 'agree': 0.34; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'characters': 0.36; 'should': 0.36; 'level': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'easy': 0.60; 'back': 0.62; 'therefore': 0.65; 'august': 0.66; 'press': 0.71; 'url:help': 0.72; 'funny': 0.78; '1st': 0.81; 'moron': 0.84; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Tkinter bug in Entry widgets on OS X Date: Sat, 01 Sep 2012 12:30:43 +0200 Organization: None References: <624248hoth2ih6bu6jvnvehokbenn0a555@invalid.netcom.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084bc35.dip.t-dialin.net User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346495467 news.xs4all.nl 6951 [2001:888:2000:d::a6]:41705 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28209 Arnaud Delobelle wrote: > On Friday, 31 August 2012, Dennis Lee Bieber wrote: > >> On Fri, 31 Aug 2012 15:41:01 GMT, Alister >> >> > >> declaimed the following in gmane.comp.python.general: >> >> > I agree that it is unexpected in a single line entry box but isn't the >> 1st >> > rule of user interface design to assume the user is a moron & will do >> > things they are not supposed to do? >> > >> > Therefore invalid inputs should be handled gracefully (not just insert >> > random characters) which is what I think the original poster is >> > suggesting. >> >> To which I'd suggest the programmer (vs the user), probably needs >> to >> code some sort of per-character validation check... After all, there may >> be situations where accepting pretty much any key-code is desired, and >> if the widget filters characters before they get to the programmer level >> that becomes impossible. >> >> > It would be good if I could intercept the key press event and cancel its > action on the Entry widget. It's easy to intercept the key event, but I > haven't found out how to prevent the funny characters from being inserted > into the Entry widget input area. Untested as I have no Mac: import Tkinter as tk def suppress(event): if event.keycode in {111, 116}: print "ignoring", event.keycode return "break" print event.keycode, "accepted" root = tk.Tk() entry = tk.Entry(root) entry.bind("", suppress) entry.pack() root.mainloop() > I've struggled to find good tkinter > docs on the web. For my (basic) needs I keep coming back to http://infohost.nmt.edu/tcc/help/pubs/tkinter/