Spinbox cursor & size / Layout margin

Hi guys,

I’m trying to design a config page featuring multiple spinboxes. Implementing the spinboxes wasn’t a problem, but styling them is kinda confusing me.
First of all I would like to easily hide the cursors and only show it upon interacting with the widget.
In C it seems to be possible to just call lv_textarea_set_cursor_hidden, but in micropython only the textarea widget seems to have this method (?), which means I somehow need to access the underlying textarea of the spinbox in order to hide the cursor, but how do I do this in micropython? I was looking for some kind of Getter but didn’t find one.

Furthermore I would like to modify the padding/margin plus spinbox height a little bit in order to make it fit the screen properly without any scrolling. I think the margin/padding marked in red in the screenshot is coming from the container itself. Doc says Keep pad_right space on the right, pad_top space on the top and pad_inner space between the children.
Is there a way to decrease the padding/margin between the different widgets in the column?

self.cont = lv.cont(page, None)
self.cont.align_mid(None, lv.ALIGN.CENTER,0,0)

Next thing is that I would like to change the size of the spinbox itself and I suppose this is not easy at all. I would like to have a decreased height and maybe even change the font, is this possible?

Best regards


To solve this, you need to add a new C function like this in lv_spinbox.h and rebuild the firmware:

static inline void lv_spinbox_set_cursor_hidden(lv_obj_t * ta, bool hide)
    lv_textarea_set_cursor_hidden(ta, hide);

If it works as expected - please submit a Pull Request to LVGL GitHub repo.

As a workaround you could also do something like lv.textarea.__cast__(spinbox).set_cursor_hidden(True) but it’s obviously less recomended.

These questions are not specific to Micropython and apply to C as well.
I recommend asking them under “How To” category to get more responses.

1 Like

Thanks, the workaround worked fine, I will try to add a new function in the evening and might submit a pull request upon success.

I will move my other questions to the specific category.