Path: csiph.com!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'configure': 0.04; 'skip:` 10': 0.05; 'attributes': 0.07; 'classes.': 0.07; 'completeness': 0.07; 'width': 0.07; '40,': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'gui': 0.11; 'cases': 0.15; '????????': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'name...': 0.16; 'securities,': 0.16; 'subject:Tkinter': 0.16; 'subject:access': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.17; 'widget': 0.17; 'thanks,': 0.18; 'idea': 0.24; 'cc:2**1': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'cc:addr:gmail.com': 0.27; 'accuracy': 0.27; 'label': 0.27; 'helpful.': 0.29; 'question:': 0.29; "i'm": 0.29; 'classes': 0.30; 'usually': 0.30; 'skip:\xd0 10': 0.33; 'venture': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'false': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'created': 0.36; 'but': 0.36; 'wanted': 0.36; 'method': 0.36; 'should': 0.36; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'easier': 0.38; 'sure': 0.38; 'instead': 0.39; 'little': 0.39; 'skip:" 10': 0.40; 'information,': 0.63; 'url:email': 0.63; 'here': 0.65; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; '8bit%:100': 0.70; 'sale': 0.76; 'widgets:': 0.84; 'received:209.85.220.184': 0.91 Newsgroups: comp.lang.python Date: Tue, 16 Oct 2012 22:35:29 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=128.69.71.8; posting-account=xl9-GQoAAACPcxqjfxLnmwPQvAoNXyyR References: <40621ce6-1b68-4cfa-8baf-cbfefce4f32b@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 128.69.71.8 MIME-Version: 1.0 Subject: Re: Tkinter how to access the widget by name From: =?UTF-8?B?0JLQu9Cw0LTQuNC80LjRgCDQn9GL0LvQtdCy?= To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: =?UTF-8?B?0JLQu9Cw0LTQuNC80LjRgCDQn9GL0LvQtdCy?= , "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 125 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350452138 news.xs4all.nl 6862 [2001:888:2000:d::a6]:60965 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31468 =D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 16 =D0=BE=D0=BA=D1=82=D1=8F=D0= =B1=D1=80=D1=8F 2012=C2=A0=D0=B3., 2:26:22 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C= =D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Prasad, Ramit =D0=BD=D0=B0= =D0=BF=D0=B8=D1=81=D0=B0=D0=BB: > ???????? ????? wrote: >=20 > > I'm a little teapot ... himself the question: if I want to appeal to th= e widget, knowing his name... ? >=20 > >=20 >=20 > > # appropriated the name of the widget >=20 > > label =3D Label(frame, width =3D 40, text=3D'text', name =3D 'name') >=20 > > ... >=20 > > name_=3D'name' >=20 > > configure(name_) >=20 > > ... >=20 > > def configure(name_) >=20 > > #And how can that be? >=20 > > # At least let the text you want to change .... >=20 > >=20 >=20 > > I beg you ..!!!! >=20 > > -- >=20 >=20 >=20 > I am unfamiliar with Tkinter, so this might not be very helpful. >=20 >=20 >=20 > Usually with the GUI I have created before I uses classes and store=20 >=20 > the widgets inside the classes. That makes it easier to use >=20 > `self.widgetname` or `getattr(self, widgetname)`. If that is not >=20 > something you can instead store the attributes in a list/dictionary. >=20 > In both cases make sure not to have multiple widgets created with >=20 > the same name. >=20 >=20 >=20 > Note the following is all untested and should be considered pseudo-code. >=20 >=20 >=20 > widgets =3D {} >=20 > label =3D Label(frame, width =3D 40, text=3D'text', name =3D 'name') >=20 > widgets['name'] =3D label >=20 >=20 >=20 > def configure(name_): >=20 > widget =3D widgets[name_]=20 >=20 >=20 >=20 > OR >=20 >=20 >=20 > widgets =3D [] >=20 > label =3D Label(frame, width =3D 40, text=3D'text', name =3D 'name') >=20 > widgets.append( label ) >=20 >=20 >=20 > def configure(name_): >=20 > found =3D False >=20 > for w in widgets: >=20 > if w.name =3D=3D name_: # No idea how to get name from Tk widget >=20 > found =3D True >=20 > break >=20 > if found: >=20 > # configure here >=20 >=20 >=20 >=20 >=20 > Ramit Prasad >=20 >=20 >=20 >=20 >=20 > This email is confidential and subject to important disclaimers and >=20 > conditions including on offers for the purchase or sale of >=20 > securities, accuracy and completeness of information, viruses, >=20 > confidentiality, legal privilege, and legal entity disclaimers, >=20 > available at http://www.jpmorgan.com/pages/disclosures/email. ok thanks, that this method is suitable in full: "widgets.append( label )" = , =D0=B0lthough at the beginning wanted to access the widget by its interna= l name, but I left this venture )).