peterhinch / micropython-micro-gui

A lightweight MicroPython GUI library for display drivers based on framebuf, allows input via pushbuttons. See also micropython-touch.
MIT License
269 stars 40 forks source link

Bug: Listbox widget does not support monochrome displays #40

Closed erichiggins closed 1 year ago

erichiggins commented 1 year ago

My setup:

Issue details:

Note: The lack of monochrome support may affect other widgets as well, though I have only run into it with Listbox so far.

The Listbox widget only supports an alternate bgcolor to indicate which item is selected. There are two issues with this:

  1. It doesn't work on monochrome displays
  2. If a Listbox only has two options, it's not always clear which item is actually selected

Alternative suggestions

There are a few other ways to approach this problem and resolve the issue for monochrome displays:

  1. Invert colors for selected elements
    • simple swap of fgcolor and bgcolor
    • could define a special "color" named INVERT within colors.py to trigger this within the widget by defining select_color=INVERT
  2. Draw border around selected item
    • Visually, I don't prefer this option though it could be easier to implement
  3. Define a character (e.g. > or -) to prepend to the selected item in the list
    • Requires the code to offset the text for the list to make room
    • Example:
      Red
      > Orange
      Yellow
      Green
peterhinch commented 1 year ago

I think this is an issue with many of the more complex controls. The gui makes extensive use of color. Greyscale monochrome displays work fairly well, but 1-bit monochrome displays don't. Perhaps I should point this out in the docs. 1-bit displays are OK for the simpler controls, but supporting the more complex controls would require substantial redesign.

I can't envisage undertaking this: I don't believe there is significant demand. Feel free to create your own fork!