What I would like to achieve is something like a self-checkout Kiosk.
So I would like to scan some barcodes. And have kivy screen show the list of item scanned. And when I have no more barcodes to scan, be able to press a button and calculate the price of all the items scanned.
I thought the best way to go about it is a while loop that keeps asking for inputs from the barcode scanner. And be able to break it by pressing a button on screen.
The problem is: when the loop is listening for input, all the buttons on screen hangs and cannot be pressed. So let's say I have no more barcode to scan but because the loop is still listening for input, the whole screen hangs. And i can't do anything except to terminate the whole script on terminal.
How should i go about resolving this problem?
How do these self checkout kiosks work? How are their codes like?
I read some suggestion about kivy clock. But even then when it reaches the part of the code that asks for input, it hangs.
What about "select", "subprocessing" or "threading"? Do you think it will resolve my problem? However, even after reading up on it, i have no clue how to implement it. If it is the right way to go about it, might you suggest some example code, pls?
I am using a mac, python 2.7, eventually would be running it on raspberry pi with LCD screen.
Here is my loop:
def getItem():
while True:
answer = input('What is the box ID? ')
if answer == 999: # to break out from loop
break
elif type(answer) == int:
display on kivy screen
else:
print('Sorry I did not get that')
here's what it looks like on kivy:
Updated code:
this is in the kv file:
<ScreenTwo>:
member_status: memberStatus
box_no: boxNo
text_in: textIn
BoxLayout:
Label:
id: memberStatus
text: ''
GridLayout:
rows: 3
padding: [100,500]
spacing: 10
BoxLayout:
Label:
id: boxNo
text: ''
BoxLayout:
TextInput:
id: textIn
write_tab: False
multiline: False
on_text_validate:
root.sayHello()
self.text = ""
self.focus = True
#also tried root.inputFocus()
BoxLayout:
CustButton:
text: "Done"
on_press:
root.manager.transition.direction = "right"
root.manager.current = 'menu'
root.clearField()
this is in the py file:
class ScreenTwo(Screen):
text_in = ObjectProperty(None)
def inputFocus(self):
self.manager.screen_two.text_in.focus = True