Well, here are some clues - the "multiple" inheritance doesn't seem to work
the way the manual *implies* it should i.e. multiple inheritance is
described as searching for methods in the first inheritance and then all
it's ancestors, then onto the next and all its ancestors and so on.

To get an "insert" (Listbox) method on your class you need to invoke the
__init__ method on the super classes (sub-classes should always invoke the
initialisation of their super class anyway - so that is something your class
definition is definitely missing!) i.e.

   Listbox.__init__(self)

If you do just this, then ScrolledList has the Listbox attributes (and none
of the others). If you then add initialisation of Scrollbar then you have
this:

    Listbox.__init__(self)
    Scrollbar.__init__(self)

And viola! ScrolledList now has the methods of Scrollbar - and "lost" the
methods of Listbox.

So without being any kind of expert on Tk objects with inheritance etc it
looks very much as though you have attempted too simplistic an approach to
creating what amounts to a "composite" object.

I would suggest that you pick one of your 3 objects to do the real
inheritance - and then create actual methods on ScrolledList that
"duplicate" the methods of the other object methods. That is the only way I
can see you get this working at the moment.

Hope this helps
Peter

On Wed, Aug 6, 2008 at 6:23 PM, vtcodger <[EMAIL PROTECTED]> wrote:

>
> Ron -- Thanks, I thought I was doing about what you describe, but
> apparently
> not as the tk attribute for the class objects is not getting set up.  I'm a
> bit hazy on what the tk attribute does (other than making things work) and
> can't find much about it via Google.  I'll go back and subclass from frame
> rather than trying to multiply inherit from Frame, List, and Scrollbar.
>
> Peter -- Thanks also.  I was aware of the PMW scrolledlist.  And it works
> fine.  But I don't want to use any components that are not part of the
> standard Python distribution.  Should have mentioned that, but the post was
> getting overlong.
>
> ===
>
> As a practical matter, I discovered after I posted, that I can access my
> frame, list (and probably scrollbar as well) methods from the main program
> via their objects.  That is to say that the way I did it, a scrolled list
> object sl doesn't have a directly usable grid or insert method, but
> sl.f.grid(... or sl.l.insert seem to work fine.
>
> What bothers me, isn't that I can't get things to work.  It's that I
> clearly
> don't understand what is going on.
> --
> View this message in context:
> http://www.nabble.com/Creating-a-new-widget-class-tp18802754p18846448.html
> Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss@python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to