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
247 stars 37 forks source link

Bug: Widgets do not respect the "no-border" setting `bdcolor=False` #39

Closed erichiggins closed 10 months ago

erichiggins commented 10 months ago

My setup:

Issue details:

Using a ListBox widget, I've tried the following to remove the outer border:

None of these appear to work reliably, though I have noticed that occasionally they render correctly without the border when navigating through my menu.

Potentially related: the code does not appear to match the documentation:

The docs for Listbox widget:

https://github.com/peterhinch/micropython-micro-gui/blob/main/README.md#67-listbox-widget

bdcolor=False Color of border. If False no border will be drawn. If a color is provided, a border line will be drawn around the control.

The code in Widget.__init__

It is checking for None rather than False, which doesn't match the docs nor the default argument values defined in Listbox.__init__:

https://github.com/peterhinch/micropython-micro-gui/blob/main/gui/core/ugui.py#L684

snippet of line linked above:

        if bdcolor is None:
            bdcolor = fgcolor
peterhinch commented 10 months ago

If I amend demos/lisbox.py so that bdcolor=False, no border is drawn unless the listbox has focus. In this case it shows a white border. If the listbox has the focus and is in adjustment mode, a LIGHTGREEN border is shown. This is in common with other adjustable widgets, a special border is drawn to indicate focus, adjustment or precision modes. The bdcolor arg defines the border color when a control does not have the focus.

These colors can be varied using the color_map in colors.py, but the changes will affect all controls.

As far as I can see the control behaves as per the docs. Feel free to open a new issue if you can produce a version of the listbox demo that exhibits a problem.