From bbd8f9b28237f95815936c49b66c2260fe82ee07 Mon Sep 17 00:00:00 2001 From: "Peter D. Gray" Date: Mon, 30 Sep 2024 14:29:46 -0400 Subject: [PATCH] generalize number entry (mk4) --- shared/ux_mk4.py | 9 +++++++-- shared/ux_q1.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/shared/ux_mk4.py b/shared/ux_mk4.py index 5ebcd2ea..ebc23ed3 100644 --- a/shared/ux_mk4.py +++ b/shared/ux_mk4.py @@ -122,7 +122,7 @@ async def ux_enter_number(prompt, max_value, can_cancel=False): # cleanup leading zeros and such value = str(min(int(value), max_value)) -async def ux_input_numbers(val): +async def ux_input_numbers(val, prompt=None, maxlen=32): # collect a series of digits from glob import dis from display import FontTiny @@ -137,6 +137,11 @@ async def ux_input_numbers(val): dis.clear() dis.text(None, -1, footer, FontTiny) + + if prompt: + dis.text(0, 0, prompt) + y += 8 + dis.save() while 1: @@ -169,7 +174,7 @@ async def ux_input_numbers(val): # quit if they press X on empty screen return else: - if len(here) < 32: + if len(here) < maxlen: here += ch async def ux_input_text(pw, confirm_exit=True, hex_only=False, max_len=100, min_len=0, **_kws): diff --git a/shared/ux_q1.py b/shared/ux_q1.py index dbc229ab..fd73fb9d 100644 --- a/shared/ux_q1.py +++ b/shared/ux_q1.py @@ -141,10 +141,10 @@ async def ux_enter_number(prompt, max_value, can_cancel=False): # cleanup leading zeros and such value = str(min(int(value), max_value)) -async def ux_input_numbers(val): +async def ux_input_numbers(val, **kws): # collect a series of digits # - not wanted on Q1; just get the digits mixed in w/ the text. - pass + raise NotImplementedError async def ux_input_text(value, confirm_exit=False, hex_only=False, max_len=100, prompt='Enter value', min_len=0, b39_complete=False, scan_ok=False,