Major update of all demo programs to use new PEP8 bindings, etc

This commit is contained in:
PySimpleGUI 2019-10-23 16:10:03 -04:00
parent 3f7c87c562
commit 7f52778bcc
307 changed files with 19546 additions and 3297 deletions

View file

@ -1,29 +1,30 @@
#!/usr/bin/env python
import sys
import sys
if sys.version_info[0] >= 3:
import PySimpleGUI as sg
else:
import PySimpleGUI27 as sg
import PySimpleGUI as sg
import hashlib
import os
'''
Find dups with PySimpleGUI
'''
# ====____====____==== FUNCTION DeDuplicate_folder(path) ====____====____==== #
# Function to de-duplicate the folder passed in #
# --------------------------------------------------------------------------- #
def FindDuplicatesFilesInFolder(path):
shatab = []
total = 0
small_count, dup_count, error_count = 0,0,0
total, small_count, dup_count, error_count = [0]*4
pngdir = path
if not os.path.exists(path):
sg.Popup('Duplicate Finder', '** Folder doesn\'t exist***', path)
sg.popup('Duplicate Finder', '** Folder doesn\'t exist***', path)
return
pngfiles = os.listdir(pngdir)
total_files = len(pngfiles)
for idx, f in enumerate(pngfiles):
if not sg.OneLineProgressMeter('Counting Duplicates', idx + 1, total_files, 'Counting Duplicate Files'):
if not sg.one_line_progress_meter('Counting Duplicates',
idx + 1,
total_files,
'Counting Duplicate Files'):
break
total += 1
fname = os.path.join(pngdir, f)
@ -42,8 +43,10 @@ def FindDuplicatesFilesInFolder(path):
continue
shatab.append(f_sha)
msg = '{} Files processed\n {} Duplicates found'.format(total_files, dup_count)
sg.Popup('Duplicate Finder Ended', msg)
msg = '{} Files processed\n {} Duplicates found'.format(
total_files, dup_count)
sg.popup('Duplicate Finder Ended', msg)
# ====____====____==== Pseudo-MAIN program ====____====____==== #
# This is our main-alike piece of code #
@ -54,9 +57,10 @@ def FindDuplicatesFilesInFolder(path):
if __name__ == '__main__':
source_folder = None
source_folder = sg.PopupGetFolder('Duplicate Finder - Count number of duplicate files', 'Enter path to folder you wish to find duplicates in')
source_folder = sg.popup_get_folder(
'Duplicate Finder - Count number of duplicate files', 'Enter path to folder you wish to find duplicates in')
if source_folder is not None:
FindDuplicatesFilesInFolder(source_folder)
else:
sg.PopupCancel('Cancelling', '*** Cancelling ***')
sg.popup_cancel('Cancelling', '*** Cancelling ***')
exit(0)