Newbie question: Classes

Sam Garson peanut.sam at googlemail.com
Wed Jan 9 14:09:06 CET 2008


OK i've kind of got that. The only thing left is calling the class.

"
class Remember:

    def __init__(self, master):

        self.ent = Entry(self, ...

root = Tk()

app = Remember(root)
"
I get the error "Remember instance has no attribute 'tk' "...???




On Jan 8, 2008 7:36 PM, Sam Garson <peanut.sam at googlemail.com > wrote:

> Hello all
>
> Basically, I have created a program using tkinter without using any class
> structure, simply creating widgets and functions (and finding ways around
> passing variables from function to function, using global variables etc).
> The program has become rather large ( lines?) I am trying to now put it into
> a class structure, because I hear it is easier to handle.
>
> So basically, I put all the stuff into a class, making the widgets in the
> "def __init__(self, root)" (root being my Tk() ) and then I have had to put
> a "self." in front of any instance of any variable or widget. Is this right?
> it seems like nothing is any easier (except having variables locally). Is
> this right? Should I be creating more classes for different things or what?
>
> I can upload the .py if you want.
>
> Thanks,
>
> Sam
>
> --
> I intend to live forever - so far, so good.
>
> SaM




-- 
I intend to live forever - so far, so good.

SaM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080109/ba027786/attachment.html>


More information about the Python-list mailing list