def makeWidgets(self): self.name = Label(self, text='None', bg='red', relief=RIDGE) self.name.pack(fill=X) SlideShow.makeWidgets(self) Button(self, text='Note', command=self.onNote).pack(fill=X) Button(self, text='Help', command=self.onHelp).pack(fill=X) s = Scale(label='Speed: msec delay', command=self.onScale, from_=0, to=3000, resolution=50, showvalue=YES, length=400, tickinterval=250, orient='horizontal') s.pack(side=BOTTOM, fill=X) s.set(self.msecs) # 1.2: need to know if editor destroyed, in popup or full component modes self.editorGone = False class WrapEditor(self.editclass): # extend PyEdit class to catch Quit def onQuit(editor): # editor is PyEdit instance arg subject self.editorGone = True # self is slide show in enclosing scope self.editorUp = False self.editclass.onQuit(editor) # avoid recursion # attach editor frame to window or slideshow frame if issubclass(WrapEditor, TextEditorMain): # make editor now self.editor = WrapEditor(self.master) # need root for menu else: self.editor = WrapEditor(self) # embedded or pop-up self.editor.pack_forget() # hide editor initially self.editorUp = self.image = None
def makeWidgets(self): self.name = Label(self, text='None', bg='red', relief=RIDGE) self.name.pack(fill=X) SlideShow.makeWidgets(self) Button(self, text='Note', command=self.onNote).pack(fill=X) Button(self, text='Help', command=self.onHelp).pack(fill=X) s = Scale(label='Speed: msecs delay', command=self.onScale, from_=0, to=3000, resolution=50, showvalue=YES, length=400, tickinterval=250, orient='horizontal') s.pack(side=BOTTOM, fill=X) s.set(self.msecs) # 1.2: 在弹窗或全组件模式中,如果销毁了编辑器则需要知道 self.editorGone = False class WrapEditor(self.editclass): # 扩展 PyEdit 类至捕获退出 def onQuit(editor): # 编辑器时 PyEdit 实例参数面向对象 self.editorGone = True # 在封闭范围中自身是幻灯片放映 self.editorUp = False self.editclass.onQuit(editor) # 避免递归 # 附加编辑器框架至窗口或幻灯片放映框架 if issubclass(WrapEditor, TextEditorMain): # 现在制造编辑器 self.editor = WrapEditor(self.master) # 需要根菜单 else: self.editor = WrapEditor(self) # 嵌入或弹出 self.editor.pack_forget() # 开始隐藏编辑器 self.editorUp = self.image = None
def makeWidgets(self): self.name = Label(self, text='None', bg='red', relief=RIDGE) self.name.pack(fill=X) SlideShow.makeWidgets(self) Button(self, text='Note', command=self.onNote).pack(fill=X) Button(self, text='Help', command=self.onHelp).pack(fill=X) s = Scale(label='Speed: msec delay', command=self.onScale, from_=0, to=3000, resolution=50, showvalue=YES, length=400, tickinterval=250, orient=HORIZONTAL) s.pack(side=BOTTOM, fill=X) s.set(self.msecs) self.editorGone = False class WrapEditor(self.editclass): def onQuit(editor): self.editorGone = True self.editorUp = False self.editclass.onQuit(editor) if issubclass(WrapEditor, TextEditorMain): self.editor = WrapEditor(self.master) else: self.editor = WrapEditor(self) self.editor.pack_forget() self.editorUp = self.image = None
def makeWidgets(self): self.name = Label(self, text='None', bg='red', relief=RIDGE) self.name.pack(fill=X) SlideShow.makeWidgets(self) Button(self, text='Note', command=self.onNote).pack(fill=X) Button(self, text='Help', command=self.onHelp).pack(fill=X) s = Scale(label='Speed: msec delay', command=self.onScale, from_=0, to=3000, resolution=50, showvalue=YES, length=400, tickinterval=250, orient='horizontal') s.pack(side=BOTTOM, fill=X) s.set(self.msecs) if self.editclass == TextEditorMain: # make editor now self.editor = self.editclass(self.master) # need root for menu else: self.editor = self.editclass(self) # embedded or popup self.editor.pack_forget() # hide editor initially self.editorUp = self.image = None
def makeWidgets(self): self.name = Label(self, text="None", bg="red", relief=RIDGE) # 顶部label,显示图片文件名 self.name.pack(fill=X) SlideShow.makeWidgets(self) # 执行父类布局 Button(self, text="Note", command=self.onNote).pack(fill=X) # 添加两个按钮 Button(self, text="Help", command=self.onHelp).pack(fill=X) s = Scale( label="Speed: msec delay", command=self.onScale, # 添加Scale刻度组件 from_=0, to=3000, resolution=50, showvalue=YES, length=400, tickinterval=250, orient="horizontal", ) s.pack(side=BOTTOM, fill=X) s.set(self.msecs) # 1.2: need to know if editor destroyed, in popup or full component modes self.editorGone = False class WrapEditor(self.editclass): # extend PyEdit class to catch Quit def onQuit(editor): # editor is PyEdit instance arg subject self.editorGone = True # self is slide show in enclosing scope #使编辑器消除标记置为True,说明其已被destroy self.editorUp = False # 这里的self是嵌套作用域中的self,指的是 self.editclass.onQuit(editor) # avoid recursion #SlideShowPlus实例,而editor则是编辑器实例 # attach editor frame to window or slideshow frame #如果传进来的editclass是TextEditorMain类型 if issubclass(WrapEditor, TextEditorMain): # make editor now #那么需要传递父窗体给编辑器的构造函数,因为它 self.editor = WrapEditor(self.master) # need root for menu #需要构造基于窗体的menu,TextEditorMainPopup else: # 不需要是因为它内部使用了一个toplevel作为父窗体 self.editor = WrapEditor(self) # embedded or pop-up self.editor.pack_forget() # hide editor initially 刚开始应该隐藏编辑框 self.editorUp = self.image = None