Closed jdtsmith closed 3 years ago
@jdtsmith - I cannot reproduce the problem you are seeing.
See this example that works as expected:
scr = lv.obj()
btn = lv.btn(scr)
btn.set_align(lv.ALIGN.CENTER)
Could you send an example that shows the problem?
Hmm, I see that it does indeed work for some elements. Here's a reproduction using a textarea
, which is where I have noticed the issue:
ta = lv.textarea(lv.scr_act())
ta.set_style_bg_color(lv.color_black(),0)
ta.set_height(lv.scr_act().get_height()//2)
ta.set_align(lv.ALIGN.BOTTOM_MID) # Doesn't work
ta.set_style_align(lv.ALIGN.BOTTOM_MID,0) # Works
ta.set_align(lv.ALIGN.TOP_MID) # Doesn't work
ta.align(lv.ALIGN.TOP_MID, 0, 0) # Works
That's because lv_textarea_set_align
has a different meaning than lv_obj_set_align
.
See https://forum.lvgl.io/t/spinbox-text-centering-not-working-as-intended-expected/6762?u=amirgon
Aha, thanks. So it's an inconsistency in the LVGL API, which it looks like they have now deprecated (_"Deprecated: use the normal textalign style property instead").
I'll patch around it.
The micropython bindings for object alignment include the three methods
align
,set_align
, andset_style_align
.align
andset_style_align
work (the former with x,y offsets), butset_align
does not function in a recent build, silently ignoring its inputs.