Changed MsgBox to Popup, fix for when button target is key
This commit is contained in:
parent
5fbfed05f7
commit
91a3178c7b
2 changed files with 12 additions and 8 deletions
|
@ -5,16 +5,18 @@ sg.SetOptions(button_color=sg.COLOR_SYSTEM_DEFAULT)
|
|||
def GetFilesToCompare():
|
||||
with sg.FlexForm('File Compare') 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.Text('File 1', size=(15, 1)), sg.InputText(key='file1'), sg.FileBrowse()],
|
||||
[sg.Text('File 2', size=(15, 1)), sg.InputText(key='file2'), sg.FileBrowse(target='file2')],
|
||||
[sg.Submit(), sg.Cancel()]]
|
||||
button, values = form.LayoutAndRead(form_rows)
|
||||
return button, values
|
||||
|
||||
def main():
|
||||
button, (f1, f2) = GetFilesToCompare()
|
||||
button, values = GetFilesToCompare()
|
||||
f1 = values['file1']
|
||||
f2 = values['file2']
|
||||
if any((button != 'Submit', f1 =='', f2 == '')):
|
||||
sg.MsgBoxError('Operation cancelled')
|
||||
sg.PopupError('Operation cancelled')
|
||||
exit(69)
|
||||
|
||||
with open(f1, 'rb') as file1:
|
||||
|
@ -24,11 +26,11 @@ def main():
|
|||
|
||||
for i, x in enumerate(a):
|
||||
if x != b[i]:
|
||||
sg.MsgBox('Compare results for files', f1, f2, '**** Mismatch at offset {} ****'.format(i))
|
||||
sg.Popup('Compare results for files', f1, f2, '**** Mismatch at offset {} ****'.format(i))
|
||||
break
|
||||
else:
|
||||
if len(a) == len(b):
|
||||
sg.MsgBox('**** The files are IDENTICAL ****')
|
||||
sg.Popup('**** The files are IDENTICAL ****')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue