[Tutor] Class Inheritance, Beat it into the Ground

Alan Gauld alan.gauld at btinternet.com
Sat Apr 24 10:56:51 CEST 2010

"David Hutto" <smokefloat at gmail.com> wrote

> In previous post I asked about  turtle module importing from tkinter.
> But what I don't understand is why does Tkinter default it's casnvas
> to ScrolledCanvas in turtle.py, 

Tkinter doesn't. The author of the turtle module - which is not part of 
Tkinter but simply uses it - chose to use a Scrolled Canvas. Presumably 
because he wanted a canvas that scrollled!

> and then as a 'metaclass' for ScrolledCanvas in turtle it calls TK.Frame, 

Its not a meta-class its a super class - the two concepts are completely 
different and you don't want to be thinking about meta classes for a 
long time yet!

> which could have been set as a default within Tkinter itself?

No it couldn't because turtle.py didn't exist when Tkinter was created.
And even if it did you couldn't guarantee that everyone would want it that 
way. Tkinter is a generic UI framework that can be used in many 
applications. It should not be defined to suit any single application.

You appear to be struggling with the concept of module use and 
dependencies. You should be trying to create a tree structure of 
dependencies with no circular loops. turtle depends on Tkinter but 
Tkinter does not depend on turtle. And your code can depend on 
Tkinter, turtle or both. But neither module should know anything 
about your code.

Inheritance is a mechanism for taking an existing class and 
specialising it for your specific application. So turtle specialised 
Frame to produce a ScrolledCanvas which it uses to display the 


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list