ISDITO PROBLEM WITH CLASS AND TINKER

Chad Netzer cnetzer at mail.arc.nasa.gov
Wed May 14 15:19:31 EDT 2003


On Wed, 2003-05-14 at 05:21, isdito wrote:
> Hello for all the people I am new in the foro, I will like ask you,
> that I have problem with the class, in thinker I create a class to
> create a menu, in a button of that menu, have other folder, but when I
> push this button the folder return but empty, not have values.
> If any people can help me?

I don't have the time at the moment to look with great detail at your
code.  But I did notice one thing right away (it stands out because you
are using columns much wider than 80 characters).

You are using the common-for-newcommers idiom:

a = Tkinter.Button( text="foo" ).pack()

ie.  You are creating the Widget, packing it, and assigning it, all in
one go.

However, you are assigning the result of pack() to a variable, NOT the
created object itself.  The result will be None.

ie.

> print a
None

So, all your variables holding widgets are likely coming out wrong.

Hmmm, upon looking further, I see that you are also doing things like
calling Tkinter.Tk() with your __init__() methods for objects (ie.
creating new Tk() objects for each object you make.)

Well, it turns out I responded to a similar set of mistakes just
recently.  Here is the link to my previous response, which I encourage
you to study (I searched Google Groups for "Chad Netzer tkinter beginner
questions")

http://groups.google.com/groups?q=chad+netzer+beginner+questions+tkinter&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.1052354114.27200.python-list%40python.org&rnum=1


I'm curious if you, and that previous poster, somehow committed these
errors independently, or were steered that way by some book or other
resource?  Do you mind me asking what Tkinter tutorial or reference you
have been using?  I'd like to know, because I have collected a bunch of
common Tkinter mistakes by beginners, and would like to update the
appropriate documentation.


-- 

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)






More information about the Python-list mailing list