26 lines
762 B
Python
26 lines
762 B
Python
from sejf.modules.base import BaseModule, Schema, fields
|
|
from kivy.core.window import Window
|
|
|
|
|
|
class BarcodeModule(BaseModule):
|
|
text_buffer: str = ""
|
|
|
|
class ConfigSchema(Schema):
|
|
code = fields.String(missing="jp2gmd")
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(BarcodeModule, self).__init__(*args, **kwargs)
|
|
|
|
self._keyboard = Window.request_keyboard(None, self, "text")
|
|
self._keyboard.bind(on_textinput=self._on_keyboard_down)
|
|
|
|
def build(self, parent):
|
|
return None
|
|
|
|
def _on_keyboard_down(self, widget, text):
|
|
self.text_buffer += text
|
|
self.text_buffer = self.text_buffer[-len(self.config["code"]) :]
|
|
|
|
if self.text_buffer == self.config["code"]:
|
|
self.finished = True
|