[Tutor] An OO question as relates to Python.
alan.gauld@bt.com
alan.gauld@bt.com
Tue Oct 22 11:57:01 2002
> Now I have another class (class WINMENU) which allows a user
> to operate on the data in the list.
In OO terms thats BAD! Unless....
> inherit the attributes of the ScrolledList class to the
> WINMENU class.
you do this. That allows you to write specfic list
handling code but get at all of the generic stuff too.
> class WINMENU(Frame)
> .....
> class ScrolledList(options)
> def populate_list(options)
> .......
You need to reverse the order of declaration so that
the definition of WINMENU can see the ScrolledList.
Either that or move ScrolledList into its own module
- this makes it easier to reuse in the future too...
Then you can:
import ScrolledList
class WinMenu(ScrolledList.ScrolledList): # use parent in module
.....
Try drawing a picture of the classes and their relationships.
Use an arrow to show inheritance and plain lines to show
usage relationships.
Include the GUI elements for which you store handles and
any application level classes - data sources if you like.
If you want a formal notation look at UML
http://www.omg.org/
HTH,
Alan G