Renamed demo files, new demo of tabbed forms

Changed filenames to remove spaces so will be easier to work with on Linux.
This commit is contained in:
MikeTheWatchGuy 2018-07-25 06:40:14 -04:00
parent 13d99dcd75
commit 2109bdbc97
10 changed files with 2427 additions and 0 deletions

33
Demo_Compare_Files.py Normal file
View file

@ -0,0 +1,33 @@
import PySimpleGUI as sg
def GetFilesToCompare():
with sg.FlexForm('File Compare', auto_size_text=True) as form:
form_rows = [[sg.Text('Enter 2 files to comare')],
[sg.Text('File 1', size=(15, 1)), sg.InputText(), sg.FileBrowse()],
[sg.Text('File 2', size=(15, 1)), sg.InputText(), sg.FileBrowse()],
[sg.Submit(), sg.Cancel()]]
rc = form.LayoutAndShow(form_rows)
return rc
def main():
button, (f1, f2) = GetFilesToCompare()
if any((button != 'Submit', f1 =='', f2 == '')):
sg.MsgBoxError('Operation cancelled')
exit(69)
with open(f1, 'rb') as file1:
with open(f2, 'rb') as file2:
a = file1.read()
b = file2.read()
for i, x in enumerate(a):
if x != b[i]:
sg.MsgBox('Compare results for files', f1, f2, '**** Mismatch at offset {} ****'.format(i))
break
else:
if len(a) == len(b):
sg.MsgBox('**** The files are IDENTICAL ****')
if __name__ == '__main__':
main()