from time import sleep
if event.keyCode == event.VK_ENTER:
if event.source.text == event.source.parent.getComponent('Label 9').text:
#advance to next filed
event.source.parent.getComponent('Input1').requestFocusInWindow()
else:
event.source.text = "Incorrect Unit Serial Number"
sleep(3)
event.source.text = ""
Not sure why is not working properly.
event.source.text = "Incorrect Unit Serial Number"
You can’t (safely) use any form of sleep in event routines. You aren’t seeing the text display because your UI is freezing during the sleep, never giving your component (or any other) a chance to redraw themselves with the changes. You must use timer events or a timer component or an invokeLater() call to defer an action.
from time import sleep
if event.keyCode == event.VK_ENTER:
if event.source.text == event.source.parent.getComponent('Label 9').text:
#advance to next filed
event.source.parent.getComponent('Input1').requestFocusInWindow()
else:
def clickButton(button = event.source.parent.getComponent('Refresh')):
import system
button.doClick()
system.gui.messageBox("Button has been clicked!")
# Tell the system to invoke the function after
# the current event has been processed
system.util.invokeLater(clickButton)```
and I am getting this error.
Error running function from fpmi.system.invokeLater.
But it will be even better when I can call messageBox' for 3 seconds and then automatically closed and get back focus in window to correct the scan entry.
So the process look like:
Scan first entry verify against another value if not match then notify operators somehow.
Option 1. by displaying message in input text field for few seconds then automatically clear entry.
Option 2. Pop up message box with information. Unfortunately operators has only scanner to scan entries and no mouse or keyboard, so in option 2 message box will need to disappeared after few seconds automatically.
Regards
Pawel