if f_sha in shatab: # uncomment next line to remove duplicate files # os.remove(fname) dup_count += 1 # sg.Print(f'Duplicate file - {f}') # cannot current use sg.Print with Progress Meter continue shatab.append(f_sha) msg = f'{total} Files processed\n'\ f'{dup_count} Duplicates found\n' sg.MsgBox('Duplicate Finder Ended', msg) # ====____====____==== Pseudo-MAIN program ====____====____==== # # This is our main-alike piece of code # # + Starts up the GUI # # + Gets values from GUI # # + Runs DeDupe_folder based on GUI inputs # # ------------------------------------------------------------- # if __name__ == '__main__': source_folder = None rc, source_folder = sg.GetPathBox( 'Duplicate Finder - Count number of duplicate files', 'Enter path to folder you wish to find duplicates in') if rc is True and source_folder is not None: FindDuplicatesFilesInFolder(source_folder) else: sg.MsgBoxCancel('Cancelling', '*** Cancelling ***') exit(0)
""" from __future__ import print_function import os, time, sys, fitz # do some adjustments whether Python v2 or v3 if str is not bytes: import PySimpleGUI as psg mytime = time.perf_counter else: mytime = time.clock rc = False if str is bytes: imgdir = sys.argv[1] # where my files are else: rc, imgdir = psg.GetPathBox("Make a PDF from Embedded Files", "Enter file directory:") if not imgdir: raise SystemExit() t0 = mytime() # set start timer doc = fitz.open() # PDF with the pictures imglist = os.listdir(imgdir) # list of them imgcount = len(imglist) # pic count for i, f in enumerate(imglist): path = os.path.join(imgdir, f) if not os.path.isfile(path): print("skipping non-file '%s'!" % f)
Simple Image Browser based on PySimpleGUI -------------------------------------------- There are some improvements compared to the PNG browser of the repository: 1. Paging is cyclic, i.e. automatically wraps around if file index is outside 2. Supports all file types that are valid PIL images 3. Limits the maximum form size to the physical screen 4. When selecting an image from the listbox, subsequent paging uses its index 5. Paging performance improved significantly because of using PIL Dependecies ------------ Python v3 PIL """ # Get the folder containing the images from the user rc, folder = sg.GetPathBox('Image Browser', 'Image folder to open', default_path='') if not rc or not folder: sg.PopupCancel('Cancelling') raise SystemExit() # PIL supported image types img_types = (".png", ".jpg", "jpeg", ".tiff", ".bmp") # get list of files in folder flist0 = os.listdir(folder) # create sub list of image files (no sub folders, no wrong file types) fnames = [f for f in flist0 if os.path.isfile(os.path.join(folder,f)) and f.lower().endswith(img_types)] num_files = len(fnames) # number of iamges found if num_files == 0:
""" from __future__ import print_function import os, time, sys, fitz # do some adjustments whether Python v2 or v3 if str is not bytes: import PySimpleGUI as psg mytime = time.perf_counter else: mytime = time.clock rc = False if str is bytes: imgdir = sys.argv[1] # where my files are else: rc, imgdir = psg.GetPathBox("Make a PDF from Attached Files", "Enter file directory:") if not imgdir: raise SystemExit() t0 = mytime() # set start timer width, height = fitz.PaperSize("a6-l") # get paper format doc = fitz.open() # open empty PDF page = doc.newPage(width = width, # make new page height = height) # define sub rect to receive text and annotation symbols rect = fitz.Rect(0, 0, width, height) + (36, 36, -36, -36)
import PySimpleGUI as sg import os # Simple Image Browser based on PySimpleGUI # Get the folder containing the images from the user rc, folder = sg.GetPathBox('Image Browser', 'Image folder to open', default_path='A:/TEMP/PDFs') if rc is False or folder is '': sg.MsgBoxCancel('Cancelling') exit(0) # get list of PNG files in folder png_files = [folder + '\\' + f for f in os.listdir(folder) if '.png' in f] if len(png_files) == 0: sg.MsgBox('No PNG images in folder') exit(0) # create the form that also returns keyboard events form = sg.FlexForm('Image Browser', return_keyboard_events=True) # make these 2 elements outside the layout because want to "update" them later # initialize to the first PNG file in the list image_elem = sg.Image(filename=png_files[0]) filename_display_elem = sg.Text(png_files[0], size=(80, 3)) file_num_display_elem = sg.Text('File 1 of {}'.format(len(png_files)), size=(10, 1)) # define layout, show and read the form