From 36b2ef27d62c9ccd9d49161c2681f81d7d2eadd4 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 19 Dec 2018 10:11:04 -0500 Subject: [PATCH 1/2] Better logic --- DemoPrograms/Demo_Input_Validation.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/DemoPrograms/Demo_Input_Validation.py b/DemoPrograms/Demo_Input_Validation.py index 7b2ca404..c8b3dd50 100644 --- a/DemoPrograms/Demo_Input_Validation.py +++ b/DemoPrograms/Demo_Input_Validation.py @@ -20,8 +20,6 @@ while True: # Event Loop event, values = window.Read() if event in (None, 'Exit'): break - if not len(values['_INPUT_']): # if field is empty ignore - continue - if values['_INPUT_'][-1] not in ('0123456789'): # if last char entered not a digit + if len(values['_INPUT_']) and values['_INPUT_'][-1] not in ('0123456789'): # if last char entered not a digit window.Element('_INPUT_').Update(values['_INPUT_'][:-1]) # delete last char from input window.Close() From b048b05687d1fca5ab7b30538bfb525cc98560bd Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 19 Dec 2018 10:11:47 -0500 Subject: [PATCH 2/2] Logic fix --- DemoPrograms/Demo_Input_Validation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DemoPrograms/Demo_Input_Validation.py b/DemoPrograms/Demo_Input_Validation.py index c8b3dd50..0a963f0b 100644 --- a/DemoPrograms/Demo_Input_Validation.py +++ b/DemoPrograms/Demo_Input_Validation.py @@ -20,6 +20,6 @@ while True: # Event Loop event, values = window.Read() if event in (None, 'Exit'): break - if len(values['_INPUT_']) and values['_INPUT_'][-1] not in ('0123456789'): # if last char entered not a digit - window.Element('_INPUT_').Update(values['_INPUT_'][:-1]) # delete last char from input + if len(values['_INPUT_']) and values['_INPUT_'][-1] not in ('0123456789'): # if last char entered not a digit + window.Element('_INPUT_').Update(values['_INPUT_'][:-1]) # delete last char from input window.Close()