peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Apache License 2.0
3.64k stars 238 forks source link

Question: UI similar to Asterisk's menuselect? #331

Closed lighth7015 closed 3 years ago

lighth7015 commented 3 years ago

Hi,

I'm working on writing a UI similar to Asterisk's menuselect UI

Shown here: image

How difficult would it be to implement something like this?

peterbrittain commented 3 years ago

An identical UI would require some new features, but a functionally equivalent UI is easy.

Going from the big differences down to the little ones:

  1. Asciimatics doesn't support a scrolling checkbox list (those options on the right hand side), however you could put all the checkboxes in the one dialog and scroll the whole dialog.
  2. I suspect that bits of the UI get dynamically replaced based on current selections. Asciimatics doesn't do this for you, but you can trigger off of events to rewrite bits of the UI as needed.
  3. Static text at the bottom of the screen requires a second Effect - possibly a tweak to the existing Background effect, or just a suitably designed Frame to sit underneath your main dialog.
  4. Various visuals aren't quite the same - e.g. buttons with shadows, dialog box characters, scrollbars, checkbox ticks, etc. These would require changes to asciimatics, but I suspect that you don't care for that level of accuracy.

You can see most of the required logic in one of the existing asciimatics demos. Places worth looking are:

  1. Use of multiple Layouts (to get different columns in your Frame) - contact_list
  2. Use of a Background effect - contact_list
  3. Use of any widget - forms
  4. Use of on_change to trigger UI changes - contact_list
  5. Use of form validation - forms
  6. Use of buttons to act on selection - either of those demos!
  7. Use of disabled TextBox for status info - top
  8. Use of embedded colour codes to change fields - forms or terminal
  9. Change dynamic content of your UI - https://github.com/peterbrittain/asciimatics/issues/315

That last one could possibly be improved. Am happy to work with you if you need the insert/remove widget logic. Oh and that checkbox list could possibly be a new multi-select option for listboxes. Also happy to help out there.

Hope that helps!

lighth7015 commented 3 years ago

Yup! going to keep this open if I need any help doing this. 😁

peterbrittain commented 3 years ago

Any issues so far?

peterbrittain commented 3 years ago

I'm assuming it was fine... Feel free to reopen or reach out on gitter if you still need help.