开发者

How do you know when two objects can communicate?

class GuiMaker(Frame):
    #more code
    def __init__(self, parent=None):
        Frame.__init__(self, parent) 
        self.pack(expand=YES, fill=BOTH)        # make frame stretchable
        self.start()                            # for subclass: set menu/toolBar
        self.makeMenuBar()                      # done here: build menu-bar
        self.makeToolBar()                      # done here: build tool-bar
        self.makeWidgets()                      # for subclass: add middle part
    #more code

class TextEditor:
    #more code
    def start(self):
    #more code

How come self.start() will call TextEditor's开发者_高级运维 start if self refers to GuiMaker or else how come self refers to TextEditor?


Does GuiMaker inherit from TextEditor somewhere? In other words is Frame a descendant of TextEditor? That would cause TextEditor's start method to be called.

Other than that, I don't see any way for the code (as written) to have GuiMaker.start call TextEditor.start

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜