def drawNext(self): SlideShow.drawNext(self) if self.image: self.name.config(text=os.path.split(self.image[0])[1]) self.destroyer.acquire() self.switchNote() # don't let editor go away self.destroyer.release()
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=BOTH) 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, expand=YES) s.set(self.msecs) self.editor = self.image = None
def onQuit(self): self.saveNote() SlideShow.onQuit(self)
def onOpen(self): SlideShow.onOpen(self) if self.image: self.name.config(text=os.path.split(self.image[0])[1]) self.config(cursor='crosshair') self.switchNote()
def onStop(self): SlideShow.onStop(self) self.config(cursor='hand2')
def onStart(self): SlideShow.onStart(self) self.config(cursor='watch')
def __init__(self, parent, picdir, editclass, msecs=2000): self.msecs = msecs self.editclass = editclass self.destroyer = thread.allocate_lock() SlideShow.__init__(self, parent=parent, picdir=picdir, msecs=msecs)
# runs two slideshows as thread, changes 5 times/second # you might be able to go a bit faster on your machine import sys from Tkinter import * from slideShow_threads import SlideShow if len(sys.argv) == 2: picdir = sys.argv[1] else: picdir = '../gifs' root = Tk() Label(root, text="Two embedded slide shows: each side is a thread").pack() SlideShow(root, msecs=200, picdir=picdir, bd=3, relief=SUNKEN).pack(side=LEFT) SlideShow(root, msecs=200, picdir=picdir, bd=3, relief=SUNKEN).pack(side=LEFT) root.mainloop()