google / openhtf

The open-source hardware testing framework.
Apache License 2.0
530 stars 217 forks source link

User Question Buttons #1072

Open Spudmn opened 1 year ago

Spudmn commented 1 year ago

This is an update to the user.prompt. It allows up to 3 optional buttons to be displayed. The button text is returned when clicked. A typical example. sAnswewr = user.prompt('Is the LED on?',text_input=False,button_1_text="Yes",button_2_text="No",button_3_text="Cancel") Will ask the question 'Is the LED on?' and the user can click "Yes", "No" or "Cancel"


This change is Reviewable

mbenabda commented 1 year ago

Hi there,

I'm interested in more versatile user inputs as well

Using a jsonschema form description would support more use cases, including this one.

That work has already been done in the spintop-openhtf distribution, that seems not to be under active development anymore Maybe it would be worth integrating instead of reimplementing ?

Their implementation however has the caveats of not being api-compatible with the current UserInput plug, and breaking the console I/O, so maybe integrate as a FormInputPlug instead

Frontend: https://gitlab.com/tackv/spintop-openhtf/-/blob/master/src/openhtf/output/web_gui/src/app/plugs/user-input-plug.component.scss https://gitlab.com/tackv/spintop-openhtf/-/blob/master/src/openhtf/output/web_gui/src/app/plugs/user-input-plug.component.html https://gitlab.com/tackv/spintop-openhtf/-/blob/master/src/openhtf/output/web_gui/src/app/plugs/user-input-plug.component.ts

Backend: https://gitlab.com/tackv/spintop-openhtf/-/blob/master/src/openhtf/plugs/user_input.py