Page 408 -
P. 408
custom widgets and classes
The Class Exposed
This week’s interview:
Life in senior object management.
Head First: Hello, Class. It’s good of you to find Head First: Frame() has a lot of methods, too?
the time to speak to us.
Class: Too many to discuss, really. There are
Class: I assure you the inestimable pleasure is all methods to paint components on the screen and
mine. details of what to do if things change size. Frame
is a fearfully busy fellow. <beep beep> Excuse me.
Head First: So, to begin...
Hello? Yes? No, you need to stop playing track four.
Class: One moment... <hums> No, no, it’s quite all right. Goodbye.
Head First: I’m sorry. What’s that? Head First: One of your objects?
Class: Apologies. Just checking my initializer. I Class: Yes. They keep me very busy, but I’d miss
always do it when I create. them if they didn’t call.
Head First: Ah, yes. That’s your constructor, isn’t Head First: I believe when someone calls an object
it? The method you use to create objects? method, the object always asks you to get involved?
Class: Well, I’m aware that some people refer to it Class: Yes. I’m in charge of the object’s behavior. I
as a constructor, but I prefer initializer. I don’t use do think it is so important to behave properly. Don’t
it to create objects, you see. I just use it to configure you?
them once they’ve been created.
Head First: Of course! Class, thank you.
Head First: You have a lot of methods?
Class: Love the tie, by the way.
Class: Oh, more than you can possibly imagine.
Head First: In the code we’ve just seen, the
SoundPanel() class, there were only three
methods, weren’t there?
Class: Oh, dear boy, there were only three methods
defined explicitly in the class. But SoundPanel()
inherited many, many more methods from its parent
class, dear old tkinter’s Frame().
you are here 4 373

