Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31346

RE: Tkinter how to access the widget by name

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 <ramit.prasad@jpmorgan.com>
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" <ramit.prasad@jpmorgan.com>
To Владимир Пылев <clinicalfilm@gmail.com>, "python-list@python.org" <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 <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.2244.1350339981.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


???????? ????? wrote:
> I'm a little teapot ... himself the question: if I want to appeal to the widget, knowing his name... ?
> 
> # appropriated the name of the widget
> label = Label(frame, width = 40, text='text', name = 'name')
> ...
> name_='name'
> configure(name_)
> ...
> def configure(name_)
>         #And how can that be?
>         # At least let the text you want to change ....
> 
> I beg you ..!!!!
> --

I am unfamiliar with Tkinter, so this might not be very helpful.

Usually with the GUI I have created before I uses classes and store 
the widgets inside the classes. That makes it easier to use
`self.widgetname` or `getattr(self, widgetname)`. If that is not
something you can instead store the attributes in a list/dictionary.
In both cases make sure not to have multiple widgets created with
the same name.

Note the following is all untested and should be considered pseudo-code.

widgets = {}
label = Label(frame, width = 40, text='text', name = 'name')
widgets['name'] = label

def configure(name_):
    widget = widgets[name_] 

OR

widgets = []
label = Label(frame, width = 40, text='text', name = 'name')
widgets.append( label )

def configure(name_):
    found = False
    for w in widgets:
         if w.name == name_: # No idea how to get name from Tk widget
               found = True
               break
     if found:
        # configure here


Ramit Prasad


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Tkinter how to access the widget by name Владимир Пылев <clinicalfilm@gmail.com> - 2012-10-14 13:11 -0700
  RE: Tkinter how to access the widget by name "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-15 22:26 +0000
    Re: Tkinter how to access the widget by name Владимир Пылев <clinicalfilm@gmail.com> - 2012-10-16 22:35 -0700
    Re: Tkinter how to access the widget by name Владимир Пылев <clinicalfilm@gmail.com> - 2012-10-16 22:35 -0700
  Re: Tkinter how to access the widget by name woooee <woooee@gmail.com> - 2012-10-16 18:52 -0700

csiph-web