def main(): '''called only when run directly, allowing module testing''' import sys #Check the arguments if len(sys.argv) == ARG_LENGTH: print(f"Command: {sys.argv}") #Create an instance of the Photo class view_photo = PH.Photo(sys.argv[ARG_IMAGEFILE]) #Test the module by running a GUI if view_photo.filevalid: PhotoGui(view_photo) else: print("Usage: photohandler.py imagefile") PhotoGui()
def listFileDates(self): """Generate list of filenames and dates""" self.photo_namedates = list() if os.path.isdir(self.folder): for filename in os.listdir(self.folder): if filename.lower().endswith(".jpg"): aPhoto = PH.Photo(os.path.join(self.folder,filename)) if aPhoto.filevalid: if (DEBUG):print("NameDate: %s %s"% (filename,aPhoto.getDate())) self.photo_namedates.append((filename, aPhoto.getDate())) self.photo_namedates = sorted(self.photo_namedates, key=lambda date: date[DATE])
def disp_preview(self): '''Display preview and details''' #Create an instance of the Photo class self.a_photo = PH.Photo(self.filename) # Generate the preview image preview_filename = self.a_photo.preview_photo() self.photo_img = TK.PhotoImage(file=preview_filename) # anchor image to NW corner self.canvas.create_image(0, 0, anchor=TK.NW, image=self.photo_img) # Populate info_list with dates and exif data info_list = [] for key, value in self.a_photo.filedates.items(): info_list.append(key.ljust(25) + value) if self.a_photo.exifvalid: for key, value in self.a_photo.exif_info.items(): info_list.append(key.ljust(25) + str(value)) # Set listvariable with the info_list self.photo_info.set(tuple(info_list))