Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'true,': 0.05; 'tkinter': 0.07; 'to:addr:pobox.com': 0.09; 'to:addr:skip': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'listbox': 0.16; 'subclass': 0.16; 'subclassing': 0.16; 'subject:Tkinter': 0.16; 'subject:insensitive': 0.16; 'subject:make': 0.16; 'flexibility': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'written': 0.21; 'seems': 0.21; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'entries': 0.24; 'skip': 0.24; 'fairly': 0.24; "i've": 0.25; '>': 0.26; 'references': 0.26; 'header:In- Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'embed': 0.31; 'own,': 0.31; 'allows': 0.31; 'handled': 0.32; 'trouble': 0.34; 'could': 0.34; 'point.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'entry': 0.36; 'subject:?': 0.36; 'should': 0.36; 'area': 0.37; 'implement': 0.38; 'actions': 0.38; 'jason': 0.38; 'pm,': 0.38; 'either': 0.39; 'removing': 0.60; 'back': 0.62; 'maximum': 0.63; 'become': 0.64; 'within': 0.65; 'capable': 0.67; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Suqj5fdSoFHsVVCq2nqmaydE7d8hqDSa/qmVjmA2ZMY=; b=VdpNLFRG4P5Ye9jAcc9mIF3T0FKZcEWIXCAAaHjM7GRO77pq5bFJfbmMH9/NKQKgFM O8Y1mZcwTSetQgddwpfEDfRfn5BU0aaqnXX2MVwnaKtPr+dfqJG0Sa0ZzXGFaV7+DHYR CfSLTcFa/HyJ45caoOoESR63YKYVvt4/CVaqvQF2T2fjJsnXIE8NJ6cGYBeNealbzZ5L K8iCTAFi+83RpydckNcTK2giO2VtJad4Uc0+OPYFT6nLZqa6K7EulAxrcYBElmzNyKq2 RULp3ToT1sDSjpfX1jsVoVJxxr4V8wrVJPmBTE3jmUzQjSjXzLeeXlgaE0H10379NTyh PIKw== MIME-Version: 1.0 X-Received: by 10.50.164.165 with SMTP id yr5mr303140igb.38.1381441471822; Thu, 10 Oct 2013 14:44:31 -0700 (PDT) In-Reply-To: References: Date: Thu, 10 Oct 2013 17:44:31 -0400 Subject: Re: How to make Tkinter Listbox entry insensitive? From: Jason Swails To: Skip Montanaro Content-Type: multipart/alternative; boundary=089e01229ed434c5df04e869e8bd Cc: Python 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: 59 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381441480 news.xs4all.nl 15955 [2001:888:2000:d::a6]:49853 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56609 --089e01229ed434c5df04e869e8bd Content-Type: text/plain; charset=ISO-8859-1 On Thu, Oct 10, 2013 at 2:29 PM, Skip Montanaro wrote: > > Removing inappropriate entries is not much of a hack. > > True, but then I have to go through the trouble of adding them back in > should they become valid again. :-) > It seems that this could be handled fairly straight-forwardly by subclassing either Listbox or Frame to implement your own, custom widget. The trick is to retain references to every entry within the widget, but only embed it in the viewable area if it happens to be a valid entry at that point. Then all that's left is to hook events up to the proper callbacks that implement various actions of your custom widgets using what Tkinter is capable of doing. Personally I prefer to subclass Frame since it allows me the maximum flexibility (I think 90+% of the widgets I've written for my own Tkinter-based programs do this). All the best, Jason --089e01229ed434c5df04e869e8bd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

<= /div>


On Thu, = Oct 10, 2013 at 2:29 PM, Skip Montanaro <skip@pobox.com> wrote:=
> Removing inappropriat= e entries is not much of a hack.

True, but then I have to go through the trouble of adding them back i= n
should they become valid again. :-)

It seems that this could be= handled fairly straight-forwardly by subclassing either Listbox or Frame t= o implement your own, custom widget. =A0The trick is to retain references t= o every entry within the widget, but only embed it in the viewable area if = it happens to be a valid entry at that point. =A0Then all that's left i= s to hook events up to the proper callbacks that implement various actions = of your custom widgets using what Tkinter is capable of doing.

Personally I prefer to subcl= ass Frame since it allows me the maximum flexibility (I think 90+% of the w= idgets I've written for my own Tkinter-based programs do this).

All the best,
Jason
=
--089e01229ed434c5df04e869e8bd--