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


Groups > comp.lang.python > #16268

Re: tkinter

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <jason.swails@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'attribute': 0.07; 'bug.': 0.07; 'initialize': 0.07; 'method.': 0.15; 'artificially': 0.16; 'dave.': 0.16; 'it).': 0.16; 'scope.': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'thanks,': 0.18; 'instance': 0.18; 'appears': 0.19; 'cc:no real name:2**0': 0.20; 'suggest': 0.20; 'checked': 0.21; 'seconds': 0.21; '(or': 0.22; 'header:In-Reply- To:1': 0.22; 'assigning': 0.23; 'default,': 0.23; 'cc:2**0': 0.24; 'module': 0.26; 'expect': 0.26; 'import': 0.27; 'received:209.85.220': 0.27; 'variable': 0.28; 'url:mailman': 0.28; 'jason': 0.28; 'problem': 0.29; 'cc:addr:python.org': 0.29; 'nov': 0.29; 'pm,': 0.29; 'behaves': 0.30; 'case).': 0.30; 'exists,': 0.30; 'sleep': 0.30; 'useless': 0.30; 'regardless': 0.31; 'does': 0.32; 'url:listinfo': 0.32; 'message-id:@gmail.com': 0.33; 'actually': 0.33; 'rather': 0.33; 'checking': 0.34; 'leaves': 0.34; 'unless': 0.35; 'url:python': 0.36; 'question': 0.36; 'none': 0.37; 'charset:us-ascii': 0.37; 'bound': 0.37; 'skip:" 10': 0.37; 'run': 0.37; 'with.': 0.37; 'reference': 0.37; 'received:google.com': 0.37; "there's": 0.37; 'references': 0.38; 'received:209.85': 0.38; 'url:org': 0.39; 'why': 0.39; 'received:209': 0.40; 'once': 0.60; 'hope': 0.61; 'header:Message- Id:1': 0.62; 'therefore,': 0.66; 'making': 0.67; '26,': 0.67; 'dealing': 0.69; 'relevant': 0.70; '(while': 0.84; 'received:10.0.2': 0.84; 'vanishes': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=TICK9zy8SEg0MTCFdfAKGZN/Ztfh+o195pXTwn7EF4M=; b=bFk3bxy1flhi6fHrV9+8thnFHSu02igmmFKgUTCwCln9CHaWptKYIOdAcown61aJav FwjNUYSdafsFdRcZrQa7PQ2xlhkyRbxV4dgTh2GOLvxq4g8H2NPxC3NUi4lA3nZ10fPy T55vG+PFX7vVoztJN8MXcSbDcSmQ+WyWfHVY0=
Subject Re: tkinter
Mime-Version 1.0 (Apple Message framework v1251.1)
Content-Type text/plain; charset=us-ascii
From Jason Swails <jason.swails@gmail.com>
In-Reply-To <f90bb247-8263-4cc1-a7a6-3f052e6de5dd@r28g2000yqj.googlegroups.com>
Date Sat, 26 Nov 2011 18:10:40 -0500
Content-Transfer-Encoding quoted-printable
References <f90bb247-8263-4cc1-a7a6-3f052e6de5dd@r28g2000yqj.googlegroups.com>
To Dave <b49P23TIvg@stny.rr.com>
X-Mailer Apple Mail (2.1251.1)
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.3062.1322349116.27778.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1322349116 news.xs4all.nl 6878 [2001:888:2000:d::a6]:56646
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:16268

Show key headers only | View raw


The problem is that the logMode1 reference is _only_ bound to the name logMode1.  Assigning it to "variable" in the Checkbutton instance (logCheck1) does not actually generate a reference to that variable inside logCheck1.  Therefore, once the initialize method terminates, all references to logMode1 are destroyed and the variable is garbage-collected.

Therefore, that variable will be None by default, regardless of what you do to it inside "initialize", which is why the button appears unchecked.  If you create a reference to it, then the Checkbutton behaves as you'd expect (that is, it appears checked).  You can verify this easily by just making logMode1 an attribute of simpleapp_tk (replace logMode1 with self.logMode1 in every case).

You can also see this behavior by artificially lengthening the initialize method.  Import the time module and run "time.sleep(5)" at the end of initialize, and you will see the check button remain checked for 5 seconds (while the reference logMode1 survives), before the check vanishes as sleep ends and the reference leaves scope.

I would suggest that this is a checking feature rather than a bug.  The variable that you set is useless unless you plan to use the value (or if there's a case where you may use it).  If such a case exists, then you'll need a reference to that variable in the relevant scope you're dealing with.

Hope this helps,
Jason

On Nov 26, 2011, at 4:42 PM, Dave wrote:

> http://forums.devshed.com/python-programming-11/setting-tkinter-checkbox-default-graphical-state-865148.html
> Please answer this question I failed to resolve.
> Thanks,
> Dave.
> -- 
> http://mail.python.org/mailman/listinfo/python-list

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


Thread

tkinter Dave <b49P23TIvg@stny.rr.com> - 2011-11-26 13:42 -0800
  Re: tkinter Jason Swails <jason.swails@gmail.com> - 2011-11-26 18:10 -0500

csiph-web