Small issues with v7->v8

I am in the progress of migrating an app from v7 to v8. So far most issues could be solved. But so far I have two issues which I wasn’t able to solve so far:

  • Labels in “LONG_WRAP” mode aren’t centered anymore when using set_align(lv.ALIGN.CENTER). Instead the individual lines are left aligned.


label = lv.label(page)
label.set_text("This is a long line that will wrap and should be centered.");          
label.align(lv.ALIGN.TOP_MID, 0, 0)
  • The keyboard has a cancel event but there is no cancel button in the default layouts anymore (or i am too stupid to see it). Do I now have to provide a complete custom button layout if I’d like to see the cancel button?

  • Labels of (too) small buttons aren’t centered properly anymore.

Example for a “X” no being horizontally centered:

btn = lv.btn()
btn.set_size(32, 32);
label = lv.label(btn)

The Keyboard now has a button in lower left corner with a keyboard icon on it. It acts as a Cancel button.

Thanks a lot. So I was indeed too stupid. But honestly, who’s supposed to guess that a keyboard icon means “cancel”?

label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)

I meant it as “Hide keyboard”.

It’s becasue now the 0;0 coordinate means the position after the paddings. See Positions, sizes, and layouts — LVGL documentation

On buttons, there was a centering layout in v7 but it’s removed in v8. It still works:

Thanks a lot. This all works.

One further question, please: is gone. How is a windows close button now supposed to be used to close a window? The window object also has no close member or similar. Is win.del_async() the way to go?

And another one: Window now has a add_title method instead of set_title. And this new method actually adds another title. How do i now update the title? Get access to the header and its label and update that manually?

It’s really missing, but it’d be great to add it back. Would you file a PR?

You can save the return value of the win.add_title()

If win.del_async() is a valid way to close the window, why would we then want another (redundant) way to do it? Imho it makes sense to keep the API simple and avoid duplicates.

In general v8 already feels much more straight forward to me than v7.

That again works. Thanks a lot!

The only non obvious thing is how to get the window from the button. In the button’s event you see the button and need to get the parent’s parent to get the window. lv_win_get_from_button() could be moew flexible.

But then a generic “get_root_window” method may be more useful. These special buttons are probably not the only case where you want to deal with the root window of some widget.

And now a very odd issue. For some reason the meters look weird as the ticks all start in the center of the meter:


The code for this is:

import SDL
import lvgl as lv



# Register SDL display driver.
draw_buf = lv.disp_draw_buf_t()
buf1_1 = bytearray(480*10)
draw_buf.init(buf1_1, None, len(buf1_1)//4)
disp_drv = lv.disp_drv_t()
disp_drv.draw_buf = draw_buf
disp_drv.flush_cb = SDL.monitor_flush
disp_drv.hor_res = 480
disp_drv.ver_res = 320

scr = lv.obj()
meter = lv.meter(scr)
meter.align(lv.ALIGN.CENTER, 0, 0)

scale = meter.add_scale()
meter.set_scale_ticks(scale, 41, 2, 10, lv.color_hex(0xff0000));


while True:

When styling a dropdown the docs suggest to do this within a callback:

But the suggested VALUE_CHANGE callback only fires when the user has changed the selection so this cannot be used to style the list. I think the docs should suggest to use CLICKED instead as this fires when the list is being drawn.

This is fixed in master.

Excellent, thanks a lot. So will probably soon show up in the lv_micropython

Yes. If you’re impatient, you can probably just cd lib/lv_bindings/lvgl && git checkout master && git pull. Usually that works without problems as the binding generation script is quite resilient.

lv_micropython was updated.

There’s also a CI test that checks every push/pull-request on LVGL by building the latest lv_micropython with the new LVGL and running all Python examples.
So if CI tests pass it’s generally very safe to assume that the new LVGL would work with latest lv_micropython.

It was fixed a ~a week ago. Se the docs here: