Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attributes': 0.05; 'interpreter': 0.05; 'attribute': 0.07; 'python': 0.08; 'attributes,': 0.09; 'canvas': 0.09; 'folks,': 0.09; 'func': 0.09; 'tkinter': 0.09; 'worked,': 0.09; 'configure': 0.10; 'displayed': 0.10; 'am,': 0.12; 'def': 0.13; 'thanks!': 0.14; 'did.': 0.16; 'out?': 0.16; 'subject:become': 0.16; 'such.': 0.16; 'tk()': 0.16; 'up:': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'posting': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'says': 0.25; 'code': 0.25; 'import': 0.27; 'tried': 0.27; 'somebody': 0.28; 'weird': 0.29; 'problem': 0.29; 'print': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.29; 'config': 0.30; 'usually': 0.31; 'familiar': 0.32; "can't": 0.32; 'header:User-Agent:1': 0.33; 'there': 0.33; 'object': 0.33; 'driven': 0.34; 'root': 0.34; 'post': 0.36; 'but': 0.37; 'received:192': 0.37; 'help': 0.39; 'received:192.168': 0.40; 'saw': 0.67; 'lost': 0.68; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.72; 'below:': 0.80; 'to:addr:yahoo.com': 0.83; 'labels': 0.84; 'nuts': 0.84; 'wanted,': 0.84; 'pic': 0.93 Date: Wed, 21 Dec 2011 08:22:04 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 MIME-Version: 1.0 To: Muddy Coder Subject: Re: Why widgets become 'NoneType'? References: <2073cd5d-a48e-4fa3-8f68-3becbfd8ec97@o7g2000yqk.googlegroups.com> In-Reply-To: <2073cd5d-a48e-4fa3-8f68-3becbfd8ec97@o7g2000yqk.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:rxK9gyKAs1I+eww9E/GW2bsgNCGDW26j0LssnA0hjom 4iDgHGyKISdx2Gk8HYOacIL+QVKndkVMAi9NTtcXZPFb+9O3p6 Od2PsPWklPN21OmBWvXdCK2T9WaD2xtL16npvZUh6ksGdQiVfO 2CellljGs8WTBJ5olVyPkGyeIP3bXXVwsocC5H0nkPFYEZ2jAp xh//Cc4g44wwRpF0rZzS3aULo+kzTukLHkrAsE6Hpp9X5t21/Z 1J5PcUGbSDQRSVAoI+4a2CySlpDQRa3UFDEkRH4UfEhsMeb/yo /SmZmju0wNskjjYqc1DO5VTlMoMfaOcvGqnJeg6qb7Qx7WoJ/x IAqzqiiugEfPICH97ue0= Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: d@davea.name 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: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324473733 news.xs4all.nl 6911 [2001:888:2000:d::a6]:60993 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17660 On 12/21/2011 07:59 AM, Muddy Coder wrote: > Hi Folks, > > I was driven nuts by this thing: widgets lost their attributes, then I > can't configure them. Please take a look at the codes below: > > from Tkinter import * > canvas = Canvas(width=300, height=400, bg='white') > canvas.pack(expand=NO, fill=BOTH) > pic = PhotoImage(file=img) > canvas.create_image(0, 0, image=pic) > al = PhotoImage(file='a.gif') > > lbl = Label(canvas, text=x, fg='red').pack(side=LEFT) > > canvas.create_text(40,20, text='Howdy') > > the last line of code got error message, says canvas object has no > attribute of config. The same problem happened again, the code is > below: > > def make_labels(win, astr): > > labels = [] > for i in range(len(astr)): > lbl = Label(win, text=astr[i]).pack(side=LEFT ) > labels.append(lbl) > return tuple(labels) > def config_labels(atuple, func): > for lbl in atuple: > lbl.config('%s') % func > > root = Tk() > lbls = make_labels(root, 'foobar') > config_labels(lbls, "fg='red'") > > The config for Label was picked up: No attributes of config. I tried > to print type(lbls), and found Python interpreter reported as > 'NoneType'. I also tried to print out dir(lbls), fount there was no > attributes I familiar with such as config and such. What is wrong with > them? Both of the codes above WORKED, since I saw my widgets displayed > them as I wanted, but I just can't configure them as I usually did. > Can somebody help me out? I never experience such a weird thing. > Thanks! > > Cosmo When posting error messages, post it exactly and completely; do not paraphrase. -- DaveA