lvgl: lv_example_chart_6 Attribute error in chart example.

Perform all steps below and tick them with [x]

  • [x ] Read the FAQ
  • [ x] Check the related part of the Documentation
  • [x ] Update lvgl to the latest version
  • [ x] Reproduce the issue in a Simulator

Describe the bug

/examples/widgets/chart/lv_example_chart_6.py has an error in it.

Traceback (most recent call last):
  File "<stdin>", line 88, in event_cb
AttributeError: no such attribute

line88: ` lv.draw_rect(a, dsc.clip_area, draw_rect_dsc)```

The attribute error is 2 fold. lv.draw_rect and also dsc.clip_area

This problem exists in both 8.3 and 9.0. I believe it is a build issue. In the lv_mp.c file for my compiled version draw_rect is present.

there is no clip_area field for lv.obj_draw_part_dsc_t. The order of the parameters for lv.draw_rect is also wrong and the types being passed to it are incorrect as well. void lv_draw_rect(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords)

I do not believe that clip_area could actually be used because of the parameters that need to be passed to lv.draw_rect does not allow for passing 2 lv.area_t objects. Maybe the call is supposed to be lv.draw_rect(dsc.draw_ctx, draw_rect_dsc, a) Then the only thing that would need to be corrected after that would be the build in order to get lv_draw_rect exposed to MicroPython

To Reproduce

https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/1853cc5143f82842aa7b1f9f80bde64ce65845fe/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/1853cc5143f82842aa7b1f9f80bde64ce65845fe/examples/widgets/chart/lv_example_chart_6.py

https://sim.lvgl.io/v9.0/micropython/ports/javascript/index.html?script_startup=https://raw.githubusercontent.com/lvgl/lvgl/347d16b4217cef7a67566394d4b468a1307464d9/examples/header.py&script=https://raw.githubusercontent.com/lvgl/lvgl/347d16b4217cef7a67566394d4b468a1307464d9/examples/widgets/chart/lv_example_chart_6.py

you have to click on one of the dots on the chart in the example for the error to occur.

Expected behavior

not have the attribute error

I would fix the issue but I am not sure of how to go about doing it because of the need to change the compiled MicroPython used in the simulator.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 46 (43 by maintainers)

Commits related to this issue

Most upvoted comments

In this case you may wait a little with the merge. I will try to correct the Python equivalent as well.

Ah… It works now.

You are right, I was not on the latest lvgl master. lv_sim_eclipse_sdl also cannot be built with the latest master at the moment. So… things are a little tricky. I now rebuilt lv_micropython using the arch/drivers branch and the latest lvgl master and there the C code of the meter examples has changed. … and that helps! The Python meter examples need quite a few changes but I got the first one to work.

I can’t see what’s the problem here: image

image

You are right, there is no problem:

>>> help(lv.draw_ctx_t())
object struct lv_draw_ctx_t is of type lv_draw_ctx_t
  __SIZE__ -- 176
  rect -- <function>
  label -- <function>
  letter -- <function>
  img -- <function>
  img_decoded -- <function>
  line -- <function>
  polygon -- <function>
  triangle -- <function>
  arc -- <function>
  transform -- <function>
  layer_create -- <function>
  layer_adjust -- <function>
  layer_blend -- <function>
  layer_destroy -- <function>
  wait_for_finish -- <function>

So given an object c of type draw_ctx_t, we can simply call: c.rect(draw_rect_dsc, a)