On Sun, Sep 9, 2012 at 5:43 PM, leam hall <leamh...@gmail.com> wrote: > Of course, showing the code might help... > > http://bpaste.net/show/44593/ > > Thanks! > > Leam > > > On Sun, Sep 9, 2012 at 10:42 AM, leam hall <leamh...@gmail.com> wrote: >> >> I'm in the O'Reilly Python 2 class, so pointers to learning would be >> better than just answers, please. My brain is a bit slow but needs to go >> forward. >> >> Line 16 calls line 31. Rather, it is supposed to. I'm trying to figure out >> why I get >> >> File "./ch8_project.py", line 31, in change_text_color >> self.text.tag_configure('highlightline', foreground=fg_color) >> AttributeError: 'ch8_Project' object has no attribute 'text' >> >> If line 31 starts with "self." and >> >> File "./ch8_project.py", line 31, in change_text_color >> text.tag_configure('highlightline', foreground=fg_color) >> NameError: global name 'text' is not defined >> >> >> If Line 31 does not start with "self.". I understand the second problem >> but not the first. >> >> What am I missing? >> >> Thanks! >> >> Leam >> >> >> -- >> Mind on a Mission >> > > > > -- > Mind on a Mission > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
Please do not top post. --- And the problem is: add_text_widget() defines a local (function-wide) `text` object rather than a class-wide one. Just prepend the `text` object with `self.` and it will be solved. Also, if you are planning to use more than one of those, you will need to do it in another way. Bonus question: why py3k? -- Kwpolska <http://kwpolska.tk> stop html mail | always bottom-post www.asciiribbon.org | www.netmeister.org/news/learn2quote.html GPG KEY: 5EAAEA16 _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor