On Sat, 24 Apr 2010 03:41:04 pm David Hutto 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, and then as a 'metaclass' for > ScrolledCanvas in turtle it calls TK.Frame, which could have > been set as a default within Tkinter itself?
Tkinter doesn't know anything about turtle. turtle is an independent module which is built on top of Tkinter. >>> Tkinter.turtle Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> Tkinter.turtle AttributeError: 'module' object has no attribute 'turtle' Yes, Tkinter could have had a ScrolledCanvas. It could have had lots of things, you have to draw the line somewhere otherwise you end up with one giant module that does *everything*: >>> import UniversalModuleWithEverything # takes a few hours to load >>> UniversalModuleWithEverything. \ ... Klingon_Wordprocessor_With_Graphics_Imbedded_Spreadsheet().run() *wink* Tkinter doesn't do anything in turtle. turtle wants a ScrolledCanvas, and since Tkinter doesn't have one, it creates it. It uses Tkinter's Frame object as the base class (not a metaclass, metaclasses are an advanced technique which are very different). That way the ScrolledCanvas class inherits behaviour from Frame. -- Steven D'Aprano _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor