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!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.000 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; 'received:155': 0.09; 'def': 0.10; 'gui': 0.11; 'cases': 0.15; '????????': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'name...': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 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; 'to:name:python- list@python.org': 0.20; 'to:2**1': 0.23; 'received:169.254': 0.24; 'idea': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'accuracy': 0.27; 'label': 0.27; 'helpful.': 0.29; 'question:': 0.29; 'received:169': 0.29; "i'm": 0.29; 'classes': 0.30; 'usually': 0.30; 'to:addr:python-list': 0.33; 'text': 0.34; 'false': 0.35; 'something': 0.35; 'created': 0.36; 'should': 0.36; 'uses': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'easier': 0.38; 'sure': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'little': 0.39; 'information,': 0.63; 'url:email': 0.63; 'here': 0.65; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'sale': 0.76; 'received:169.254.8': 0.84; 'widgets:': 0.84 X-DKIM: OpenDKIM Filter v2.1.3 sz2.jpmchase.com q9FMQCls006792 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1350339972; bh=zq9LhZpH4OvvVqDjncyQRRy+GTKBX9YV4hrgMVCuNAw=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=HQzmwFrjHby2/Ry9HI38ojPZOkEqX6D+XCeluGFWjSJWlY//437Y4hyk90HsqIXio AyqN7HGhz9tjuM48UOcd9rvNOky26ltr/D0eWMlT9a/Ht6n/4MfFXIQakBZzlZbRik zsERomWrOQ6gDJCP5vTdnUGlrK7Obk4tcS2a0hcs= From: "Prasad, Ramit" To: =?koi8-r?B?98zBxMnNydIg8NnMxdc=?= , "python-list@python.org" Subject: RE: Tkinter how to access the widget by name Thread-Topic: Tkinter how to access the widget by name Thread-Index: AQHNqkidAvKeAczlTUCR6I18umLIMZe68FLQ Date: Mon, 15 Oct 2012 22:26:07 +0000 References: <40621ce6-1b68-4cfa-8baf-cbfefce4f32b@googlegroups.com> In-Reply-To: <40621ce6-1b68-4cfa-8baf-cbfefce4f32b@googlegroups.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.67.79.47] Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DLP-FWD: Yes Content-Type: text/plain; charset="koi8-r" 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350339981 news.xs4all.nl 6922 [2001:888:2000:d::a6]:44313 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31346 ???????? ????? wrote:=0D=0A> I'm a little teapot =2E=2E=2E himself the ques= tion: if I want to appeal to the widget, knowing his name=2E=2E=2E ?=0D=0A>= =0D=0A> # appropriated the name of the widget=0D=0A> label =3D Label(frame= , width =3D 40, text=3D'text', name =3D 'name')=0D=0A> =2E=2E=2E=0D=0A> nam= e_=3D'name'=0D=0A> configure(name_)=0D=0A> =2E=2E=2E=0D=0A> def configure(n= ame_)=0D=0A> #And how can that be?=0D=0A> # At least let th= e text you want to change =2E=2E=2E=2E=0D=0A> =0D=0A> I beg you =2E=2E!!!!= =0D=0A> --=0D=0A=0D=0AI am unfamiliar with Tkinter, so this might not be ve= ry helpful=2E=0D=0A=0D=0AUsually with the GUI I have created before I uses = classes and store =0D=0Athe widgets inside the classes=2E That makes it eas= ier to use=0D=0A`self=2Ewidgetname` or `getattr(self, widgetname)`=2E If th= at is not=0D=0Asomething you can instead store the attributes in a list/dic= tionary=2E=0D=0AIn both cases make sure not to have multiple widgets create= d with=0D=0Athe same name=2E=0D=0A=0D=0ANote the following is all untested = and should be considered pseudo-code=2E=0D=0A=0D=0Awidgets =3D {}=0D=0Alabe= l =3D Label(frame, width =3D 40, text=3D'text', name =3D 'name')=0D=0Awidge= ts['name'] =3D label=0D=0A=0D=0Adef configure(name_):=0D=0A widget =3D w= idgets[name_] =0D=0A=0D=0AOR=0D=0A=0D=0Awidgets =3D []=0D=0Alabel =3D Label= (frame, width =3D 40, text=3D'text', name =3D 'name')=0D=0Awidgets=2Eappend= ( label )=0D=0A=0D=0Adef configure(name_):=0D=0A found =3D False=0D=0A = for w in widgets:=0D=0A if w=2Ename =3D=3D name_: # No idea how t= o get name from Tk widget=0D=0A found =3D True=0D=0A = break=0D=0A if found:=0D=0A # configure here=0D=0A=0D=0A= =0D=0ARamit Prasad=0D=0A=0D=0A=0D=0AThis email is confidential and subject = to important disclaimers and=0D=0Aconditions including on offers for the pu= rchase or sale of=0D=0Asecurities, accuracy and completeness of information= , viruses,=0D=0Aconfidentiality, legal privilege, and legal entity disclaim= ers,=0D=0Aavailable at http://www=2Ejpmorgan=2Ecom/pages/disclosures/email= =2E