self drawn true none def makewidgets(self)heightwidth self size self canvas canvas(selfbg='white'height=heightwidth=widthself canvas pack(side=leftfill=bothexpand=yesself onoff button(selftext='start'command=self onstartself onoff pack(fill=xbutton(selftext='open'command=self onopenpack(fill=xbutton(selftext='beep'command=self onbeeppack(fill=xbutton(selftext='quit'command=self onquitpack(fill=xdef onstart(self)self loop true self onoff config(text='stop'command=self onstopself canvas config(height=self size[ ]width=self size[ ]self ontimer(def onstop(self)self loop false self onoff config(text='start'command=self onstartdef onopen(self)self onstop(name askopenfilename(initialdir=self opensfiletypes=imagetypesif nameif self drawnself canvas delete(self drawnimg photoimage(file=nameself canvas config(height=img height()width=img width()self drawn self canvas create_image( image=imganchor=nwself image nameimg def onquit(self)self onstop(self update(if askyesno('pyview''really quit now?')self quit(def onbeep(self)self beep not self beep toggleor use def ontimer(self)if self loopself drawnext(self after(self msecsself ontimerdef drawnext(self)if self drawnself canvas delete(self drawnnameimg random choice(self imagesself drawn self canvas create_image( image=imganchor=nwself image nameimg if self beepself bell(self canvas update( complete gui programs