From: Andy T. <an...@us...> - 2005-12-13 11:13:47
|
Update of /cvsroot/pythoncard/PythonCard/samples/slideshow In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19204/slideshow Modified Files: slideshow.py Log Message: Removed all of the plain except: clauses I could Index: slideshow.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/samples/slideshow/slideshow.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** slideshow.py 15 Aug 2004 17:34:58 -0000 1.42 --- slideshow.py 13 Dec 2005 11:13:25 -0000 1.43 *************** *** 6,13 **** """ ! from PythonCard import dialog, graphic, log, model, timer, util import wx import os, sys - from PythonCard import EXIF import zipfile from cStringIO import StringIO --- 6,12 ---- """ ! from PythonCard import dialog, graphic, log, model, timer, util, EXIF import wx import os, sys import zipfile from cStringIO import StringIO *************** *** 63,67 **** self.components.htmlView.enabled = 0 - # this is the code from pictureViewer # instead of a file argument, slideshow --- 62,65 ---- *************** *** 101,108 **** self.displayNextFile() - # need to enable keyPresses - # for backgrounds without a component that accepts - # keyPresses def on_keyPress(self, event): keyCode = event.GetKeyCode() #print keyCode --- 99,105 ---- self.displayNextFile() def on_keyPress(self, event): + # need to enable keyPresses + # for backgrounds without a component that accepts keyPresses keyCode = event.GetKeyCode() #print keyCode *************** *** 123,128 **** self.displayFile() - # always display the file limited to the current size of buffer def displayFile(self): if self.filename is not None: if htmlFile(self.filename): --- 120,125 ---- self.displayFile() def displayFile(self): + # always display the file limited to the current size of buffer if self.filename is not None: if htmlFile(self.filename): *************** *** 177,257 **** def openFile(self, path, slideNumber=None): - if self.zip: - self.openFileInZip(path, slideNumber) - return - - if not os.path.exists(path): - return - - self.filename = path - if htmlFile(path): - title = os.path.split(self.filename)[-1] - else: - f = open(path, 'rb') - tags = EXIF.process_file(f) - f.close() - try: - # the repr() is something like - # (0x0112) Short=8 @ 54 - # but the str() is just 1, 8, etc. - orientation = int(str(tags['Image Orientation'])) - #print path - #print 'Image Orientation: %d' % orientation - #print 'Thumbnail Orientation: %s' % tags['Thumbnail Orientation'] - except: - orientation = 1 - - self.bmp = graphic.Bitmap(self.filename) - if orientation == 8: - # need to rotate the image - # defaults to clockwise, 0 means counter-clockwise - #print "rotating" - self.bmp.rotate90(0) - elif orientation == 6: - self.bmp.rotate90(1) - - size = self.bmp.getSize() - title = os.path.split(self.filename)[-1] + " %d x %d" % size - - if slideNumber is not None: - title = title + " Slide: %d of %d" % (slideNumber + 1, len(self.fileList)) - self.title = title - self.displayFile() - - def openFileInZip(self, path, slideNumber=None): self.filename = path ! if htmlFile(path): title = os.path.split(self.filename)[-1] else: ! ##info = self.zip.NameToInfo[path] ! data = self.zip.read(path) ! tags = EXIF.process_file(StringIO(data)) ! #f = open(path, 'rb') ! #tags=EXIF.process_file(f) ! #f.close() ! try: # the repr() is something like # (0x0112) Short=8 @ 54 # but the str() is just 1, 8, etc. orientation = int(str(tags['Image Orientation'])) ! #print path ! #print 'Image Orientation: %d' % orientation ! #print 'Thumbnail Orientation: %s' % tags['Thumbnail Orientation'] ! except: orientation = 1 ! ! self.bmp = graphic.Bitmap() ! self.bmp.setImageBits(wx.ImageFromStream(StringIO(data))) if orientation == 8: # need to rotate the image # defaults to clockwise, 0 means counter-clockwise - #print "rotating" self.bmp.rotate90(0) elif orientation == 6: self.bmp.rotate90(1) - size = self.bmp.getSize() title = os.path.split(self.filename)[-1] + " %d x %d" % size - if slideNumber is not None: title = title + " Slide: %d of %d" % (slideNumber + 1, len(self.fileList)) --- 174,213 ---- def openFile(self, path, slideNumber=None): self.filename = path ! if htmlFile(self.filename): title = os.path.split(self.filename)[-1] else: ! if self.zip: ! data = self.zip.read(self.filename) ! tags = EXIF.process_file(StringIO(data)) ! log.debug("Getting %s from zip file" % self.filename) ! self.bmp = graphic.Bitmap() ! self.bmp.setImageBits(wx.ImageFromStream(StringIO(data))) ! else: ! if not os.path.exists(self.filename): ! return ! f = open(self.filename, 'rb') ! tags = EXIF.process_file(f) ! f.close() ! log.debug("Getting %s from file" % self.filename) ! self.bmp = graphic.Bitmap(self.filename) ! if tags.has_key('Image Orientation'): # the repr() is something like # (0x0112) Short=8 @ 54 # but the str() is just 1, 8, etc. orientation = int(str(tags['Image Orientation'])) ! else: orientation = 1 ! log.debug('Image Orientation: %d' % orientation) ! if tags.has_key('Thumbnail Orientation'): ! log.debug('Thumbnail Orientation: %s' % tags['Thumbnail Orientation']) if orientation == 8: # need to rotate the image # defaults to clockwise, 0 means counter-clockwise self.bmp.rotate90(0) elif orientation == 6: self.bmp.rotate90(1) size = self.bmp.getSize() title = os.path.split(self.filename)[-1] + " %d x %d" % size if slideNumber is not None: title = title + " Slide: %d of %d" % (slideNumber + 1, len(self.fileList)) *************** *** 262,266 **** if self.fileList is None: return - index = self.fileIndex + 1 if self.loop and index == len(self.fileList): --- 218,221 ---- *************** *** 297,301 **** interval = int(result.text) * 1000 self.interval = interval ! except: pass --- 252,256 ---- interval = int(result.text) * 1000 self.interval = interval ! except ValueError: pass *************** *** 306,310 **** f.close() self.fileList = txt.splitlines() ! except: pass --- 261,265 ---- f.close() self.fileList = txt.splitlines() ! except IOError: pass *************** *** 313,316 **** --- 268,272 ---- self.directory = path fileList = util.dirwalk(path, ['*'], recurse) + log.debug('Directory file list: %s' % fileList) # self.fileList should be filtered here self.fileList = [] *************** *** 318,331 **** for path in fileList: if imageFile(path) or htmlFile(path): - #print "path", path self.fileList.append(path) self.fileList = util.caseinsensitive_sort(self.fileList) def buildFileListFromZip(self, path): - #print path self.zip = zipfile.ZipFile(path) - #print self.zip.namelist() self.directory = None fileList = self.zip.namelist() # self.fileList should be filtered here self.fileList = [] --- 274,285 ---- for path in fileList: if imageFile(path) or htmlFile(path): self.fileList.append(path) self.fileList = util.caseinsensitive_sort(self.fileList) def buildFileListFromZip(self, path): self.zip = zipfile.ZipFile(path) self.directory = None fileList = self.zip.namelist() + log.debug('Zip file list: %s' % fileList) # self.fileList should be filtered here self.fileList = [] *************** *** 337,344 **** if ext in ['bmp', 'gif', 'jpeg', 'jpg', 'pcx', 'png', 'pnm', 'tif', 'tiff', 'xbm', 'xpm']: - #if imageFile(f) or htmlFile(f): - #print "path", path self.fileList.append(f) - #print self.fileList def on_menuSlideshowChooseZip_select(self, event): --- 291,295 ---- *************** *** 418,422 **** self.fileIndex = n self.openFile(self.fileList[self.fileIndex], self.fileIndex) ! except: pass --- 369,373 ---- self.fileIndex = n self.openFile(self.fileList[self.fileIndex], self.fileIndex) ! except ValueError: pass *************** *** 440,453 **** path = self.fileList[self.fileIndex] if imageFile(path): ! #print "image", path try: - viewer = os.path.abspath(os.path.join('..', 'pictureViewer', 'pictureViewer.py')) - if " " in path: - path = '"' + path + '"' util.runScript(viewer, path) ! except: pass elif htmlFile(path): ! #print "html", path import webbrowser webbrowser.open(path, 1, 1) --- 391,404 ---- path = self.fileList[self.fileIndex] if imageFile(path): ! log.debug("image: %s" % path) ! viewer = os.path.abspath(os.path.join('..', 'pictureViewer', 'pictureViewer.py')) ! if " " in path: ! path = '"' + path + '"' try: util.runScript(viewer, path) ! except: # Fail gracefully if displaying fails pass elif htmlFile(path): ! log.debug("html: %s" % path) import webbrowser webbrowser.open(path, 1, 1) *************** *** 458,462 **** event.skip() - if __name__ == '__main__': app = model.Application(SlideShow) --- 409,412 ---- |