style(examples) fix style issues in Python examples (#2880)

Removes all semicolons at line endings in the Python examples.
This commit is contained in:
ckielstra
2021-12-05 14:41:17 +01:00
committed by GitHub
parent 0b91b6c42f
commit a5058eafd0
47 changed files with 85 additions and 99 deletions

View File

@@ -29,7 +29,7 @@ style_indic = lv.style_t()
style_indic.init()
style_indic.set_bg_img_src(img_skew_strip_dsc)
style_indic.set_bg_img_tiled(True);
style_indic.set_bg_img_tiled(True)
style_indic.set_bg_img_opa(lv.OPA._30)
bar = lv.bar(lv.scr_act())

View File

@@ -34,5 +34,5 @@ btn1.add_style(style_pr, lv.STATE.PRESSED)
btn1.add_style(style_def, 0)
label = lv.label(btn1)
label.set_text("Gum");
label.set_text("Gum")

View File

@@ -25,7 +25,7 @@ def event_cb(e):
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
# Change the draw descriptor the 2nd button
if dsc.id == 1:
dsc.rect_dsc.radius = 0;
dsc.rect_dsc.radius = 0
if obj.get_selected_btn() == dsc.id:
dsc.rect_dsc.bg_color = lv.palette_darken(lv.PALETTE.GREY, 3)
else:
@@ -54,7 +54,7 @@ def event_cb(e):
# Add custom content to the 4th button when the button itself was drawn
if dsc.id == 3:
# LV_IMG_DECLARE(img_star);
# LV_IMG_DECLARE(img_star)
header = lv.img_header_t()
res = lv.img.decoder_get_info(img_star_argb, header)
if res != lv.RES.OK:
@@ -63,9 +63,9 @@ def event_cb(e):
else:
a = lv.area_t()
a.x1 = dsc.draw_area.x1 + (dsc.draw_area.get_width() - header.w) // 2
a.x2 = a.x1 + header.w - 1;
a.x2 = a.x1 + header.w - 1
a.y1 = dsc.draw_area.y1 + (dsc.draw_area.get_height() - header.h) // 2
a.y2 = a.y1 + header.h - 1;
a.y2 = a.y1 + header.h - 1
img_draw_dsc = lv.draw_img_dsc_t()
img_draw_dsc.init()
img_draw_dsc.recolor = lv.color_black()

View File

@@ -47,7 +47,7 @@ map = [lv.SYMBOL.LEFT,"1","2", "3", "4", "5",lv.SYMBOL.RIGHT, ""]
btnm = lv.btnmatrix(lv.scr_act())
btnm.set_map(map)
btnm.add_style(style_bg, 0);
btnm.add_style(style_bg, 0)
btnm.add_style(style_btn, lv.PART.ITEMS)
btnm.add_event_cb(event_cb, lv.EVENT.VALUE_CHANGED, None)
btnm.set_size(225, 35)
@@ -57,7 +57,7 @@ btnm.set_btn_ctrl_all(lv.btnmatrix.CTRL.CHECKABLE)
btnm.clear_btn_ctrl(0, lv.btnmatrix.CTRL.CHECKABLE)
btnm.clear_btn_ctrl(6, lv.btnmatrix.CTRL.CHECKABLE)
btnm.set_one_checked(True);
btnm.set_one_checked(True)
btnm.set_btn_ctrl(1, lv.btnmatrix.CTRL.CHECKED)
btnm.center()

View File

@@ -30,7 +30,7 @@ canvas.fill_bg(lv.palette_lighten(lv.PALETTE.GREY, 3), lv.OPA.COVER)
canvas.draw_rect(70, 60, 100, 70, rect_dsc)
canvas.draw_text(40, 20, 100, label_dsc, "Some text on text canvas")
# Test the rotation. It requires an other buffer where the orignal image is stored.
# Test the rotation. It requires an other buffer where the original image is stored.
# So copy the current image to buffer and rotate it to the canvas
img = lv.img_dsc_t()
@@ -40,4 +40,4 @@ img.header.w = _CANVAS_WIDTH
img.header.h = _CANVAS_HEIGHT
canvas.fill_bg(lv.palette_lighten(lv.PALETTE.GREY, 3), lv.OPA.COVER)
canvas.transform(img, 30, LV_IMG_ZOOM_NONE, 0, 0, _CANVAS_WIDTH // 2, _CANVAS_HEIGHT // 2, True);
canvas.transform(img, 30, LV_IMG_ZOOM_NONE, 0, 0, _CANVAS_WIDTH // 2, _CANVAS_HEIGHT // 2, True)

View File

@@ -5,7 +5,7 @@ chart.center()
chart.set_type(lv.chart.TYPE.LINE) # Show lines and points too
# Add two data series
ser1 = chart.add_series(lv.palette_main(lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y);
ser1 = chart.add_series(lv.palette_main(lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y)
ser2 = chart.add_series(lv.palette_main(lv.PALETTE.GREEN), lv.chart.AXIS.SECONDARY_Y)
print(ser2)
# Set next points on ser1

View File

@@ -44,7 +44,7 @@ def draw_event_cb(e):
def add_data(timer):
# LV_UNUSED(timer);
cnt = 0;
cnt = 0
chart1.set_next_value(ser1, lv.rand(20, 90))
if cnt % 4 == 0:

View File

@@ -28,8 +28,8 @@ chart.set_axis_tick(lv.chart.AXIS.SECONDARY_Y, 10, 5, 3, 4,True, 50)
chart.set_zoom_x(800)
# Add two data series
ser1 = lv.chart.add_series(chart, lv.palette_lighten(lv.PALETTE.GREEN, 2), lv.chart.AXIS.PRIMARY_Y);
ser2 = lv.chart.add_series(chart, lv.palette_darken(lv.PALETTE.GREEN, 2), lv.chart.AXIS.SECONDARY_Y);
ser1 = lv.chart.add_series(chart, lv.palette_lighten(lv.PALETTE.GREEN, 2), lv.chart.AXIS.PRIMARY_Y)
ser2 = lv.chart.add_series(chart, lv.palette_darken(lv.PALETTE.GREEN, 2), lv.chart.AXIS.SECONDARY_Y)
# Set the next points on 'ser1'
chart.set_next_value(ser1, 31)

View File

@@ -24,7 +24,7 @@ def event_cb(e):
draw_rect_dsc.bg_color = lv.color_black()
draw_rect_dsc.bg_opa = lv.OPA._50
draw_rect_dsc.radius = 3
draw_rect_dsc.bg_img_src = buf;
draw_rect_dsc.bg_img_src = buf
draw_rect_dsc.bg_img_recolor = lv.color_white()
a = lv.area_t()

View File

@@ -56,7 +56,7 @@ class ExampleChart_6():
# print("last_id: ",self.last_id)
if dsc.part == lv.PART.CURSOR and dsc.p1 and dsc.p2 and dsc.p1.y == dsc.p2.y and self.last_id >= 0:
v = self.ser_p[self.last_id];
v = self.ser_p[self.last_id]
# print("value: ",v)
value_txt = str(v)
@@ -66,13 +66,13 @@ class ExampleChart_6():
a = lv.area_t()
a.y2 = dsc.p1.y - 5
a.y1 = a.y2 - size.y - 10
a.x1 = dsc.p1.x + 10;
a.x2 = a.x1 + size.x + 10;
a.x1 = dsc.p1.x + 10
a.x2 = a.x1 + size.x + 10
draw_rect_dsc = lv.draw_rect_dsc_t()
draw_rect_dsc.init()
draw_rect_dsc.bg_color = lv.palette_main(lv.PALETTE.BLUE)
draw_rect_dsc.radius = 3;
draw_rect_dsc.radius = 3
lv.draw_rect(a, dsc.clip_area, draw_rect_dsc)

View File

@@ -4,9 +4,9 @@ def event_handler(e):
if code == lv.EVENT.VALUE_CHANGED:
txt = obj.get_text()
if obj.get_state() & lv.STATE.CHECKED:
state = "Checked"
state = "Checked"
else:
state = "Unchecked";
state = "Unchecked"
print(txt + ":" + state)

View File

@@ -25,8 +25,8 @@ img_cogwheel_argb = lv.img_dsc_t({
def create_slider(color):
slider = lv.slider(lv.scr_act())
slider.set_range(0, 255)
slider.set_size(10, 200);
slider.set_style_bg_color(color, lv.PART.KNOB);
slider.set_size(10, 200)
slider.set_style_bg_color(color, lv.PART.KNOB)
slider.set_style_bg_color(color.color_darken(lv.OPA._40), lv.PART.INDICATOR)
slider.add_event_cb(slider_event_cb, lv.EVENT.VALUE_CHANGED, None)
return slider

View File

@@ -69,6 +69,6 @@ imgbtn1.align(lv.ALIGN.CENTER, 0, 0)
# Create a label on the image button
label = lv.label(imgbtn1)
label.set_text("Button");
label.set_text("Button")
label.align(lv.ALIGN.CENTER, 0, -4)

View File

@@ -2,7 +2,7 @@
# Show line wrap, re-color, line align and text scrolling.
#
label1 = lv.label(lv.scr_act())
label1.set_long_mode(lv.label.LONG.WRAP); # Break the long lines*/
label1.set_long_mode(lv.label.LONG.WRAP) # Break the long lines*/
label1.set_recolor(True) # Enable re-coloring by commands in the text
label1.set_text("#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center"
"and wrap long text automatically.")

View File

@@ -4,7 +4,7 @@ import fs_driver
#
ltr_label = lv.label(lv.scr_act())
ltr_label.set_text("In modern terminology, a microcontroller is similar to a system on a chip (SoC).");
ltr_label.set_text("In modern terminology, a microcontroller is similar to a system on a chip (SoC).")
# ltr_label.set_style_text_font(ltr_label, &lv_font_montserrat_16, 0);
fs_drv = lv.fs_drv_t()

View File

@@ -13,7 +13,7 @@ def float_btn_event_cb(e):
cont = lv.menu_cont(main_page)
label = lv.label(cont)
label.set_text("Item {:d}".format(btn_cnt))
menu.set_load_page_event(cont, sub_page);
menu.set_load_page_event(cont, sub_page)
# Create a menu object
menu = lv.menu(lv.scr_act())

View File

@@ -39,7 +39,7 @@ roller.add_event_cb(event_handler, lv.EVENT.ALL, None)
roller.set_selected(2, lv.ANIM.OFF)
# A roller on the middle with center aligned text, and auto (default) width
roller = lv.roller(lv.scr_act());
roller = lv.roller(lv.scr_act())
roller.set_options(opts, lv.roller.MODE.NORMAL)
roller.set_visible_row_count(3)
roller.add_style(style_sel, lv.PART.SELECTED)
@@ -48,7 +48,7 @@ roller.add_event_cb(event_handler, lv.EVENT.ALL, None)
roller.set_selected(5, lv.ANIM.OFF)
# A roller on the right with right aligned text, and custom width
roller = lv.roller(lv.scr_act());
roller = lv.roller(lv.scr_act())
roller.set_options(opts, lv.roller.MODE.NORMAL)
roller.set_visible_row_count(4)
roller.set_width(80)

View File

@@ -93,7 +93,7 @@ class Lv_Roller_3():
# Remove the masks
lv.draw_mask_remove_id(self.mask_top_id)
lv.draw_mask_remove_id(self.mask_bottom_id)
self.mask_top_id = -1;
self.mask_bottom_id = -1;
self.mask_top_id = -1
self.mask_bottom_id = -1
roller3 = Lv_Roller_3()

View File

@@ -25,7 +25,7 @@ span.style.set_text_decor(lv.TEXT_DECOR.STRIKETHROUGH | lv.TEXT_DECOR.UNDERLINE)
span.style.set_text_opa(lv.OPA._30)
span = spans.new_span()
span.set_text_static("good good study, day day up.");
span.set_text_static("good good study, day day up.")
#if LV_FONT_MONTSERRAT_24
# lv_style_set_text_font(&span->style, &lv_font_montserrat_24);
#endif

View File

@@ -25,24 +25,24 @@ def draw_part_event_cb(e):
table = lv.table(lv.scr_act())
# Fill the first column
table.set_cell_value(0, 0, "Name");
table.set_cell_value(1, 0, "Apple");
table.set_cell_value(2, 0, "Banana");
table.set_cell_value(3, 0, "Lemon");
table.set_cell_value(4, 0, "Grape");
table.set_cell_value(5, 0, "Melon");
table.set_cell_value(6, 0, "Peach");
table.set_cell_value(7, 0, "Nuts");
table.set_cell_value(0, 0, "Name")
table.set_cell_value(1, 0, "Apple")
table.set_cell_value(2, 0, "Banana")
table.set_cell_value(3, 0, "Lemon")
table.set_cell_value(4, 0, "Grape")
table.set_cell_value(5, 0, "Melon")
table.set_cell_value(6, 0, "Peach")
table.set_cell_value(7, 0, "Nuts")
# Fill the second column
table.set_cell_value(0, 1, "Price");
table.set_cell_value(1, 1, "$7");
table.set_cell_value(2, 1, "$4");
table.set_cell_value(3, 1, "$6");
table.set_cell_value(4, 1, "$2");
table.set_cell_value(5, 1, "$5");
table.set_cell_value(6, 1, "$1");
table.set_cell_value(7, 1, "$9");
table.set_cell_value(0, 1, "Price")
table.set_cell_value(1, 1, "$7")
table.set_cell_value(2, 1, "$4")
table.set_cell_value(3, 1, "$6")
table.set_cell_value(4, 1, "$2")
table.set_cell_value(5, 1, "$5")
table.set_cell_value(6, 1, "$1")
table.set_cell_value(7, 1, "$9")
# Set a smaller height to the table. It'll make it scrollable
table.set_height(200)

View File

@@ -16,15 +16,15 @@ def draw_event_cb(e):
if chk:
rect_dsc.bg_color = lv.theme_get_color_primary(obj)
else:
rect_dsc.bg_color = lv.palette_lighten(lv.PALETTE.GREY,2)
rect_dsc.bg_color = lv.palette_lighten(lv.PALETTE.GREY, 2)
rect_dsc.radius = lv.RADIUS.CIRCLE
sw_area = lv.area_t()
sw_area.x1 = dsc.draw_area.x2 - 50;
sw_area.x2 = sw_area.x1 + 40;
sw_area.y1 = dsc.draw_area.y1 + dsc.draw_area.get_height() // 2 - 10
sw_area.y2 = sw_area.y1 + 20;
sw_area.x1 = dsc.draw_area.x2 - 50
sw_area.x2 = sw_area.x1 + 40
sw_area.y1 = dsc.draw_area.y1 + dsc.draw_area.get_height() // 2 - 10
sw_area.y2 = sw_area.y1 + 20
lv.draw_rect(sw_area, dsc.clip_area, rect_dsc)
rect_dsc.bg_color = lv.color_white()
@@ -35,8 +35,8 @@ def draw_event_cb(e):
else:
sw_area.x1 += 2
sw_area.x2 = sw_area.x1 + 16
sw_area.y1 += 2;
sw_area.y2 -= 2;
sw_area.y1 += 2
sw_area.y2 -= 2
lv.draw_rect(sw_area, dsc.clip_area, rect_dsc)
def change_event_cb(e):
@@ -60,7 +60,7 @@ def change_event_cb(e):
gc.enable()
gc.collect()
mem_free = gc.mem_free()
print("mem_free: ",mem_free)
print("mem_free: ", mem_free)
t = ticks_ms()
print("ticks: ", t)
table = lv.table(lv.scr_act())
@@ -78,7 +78,7 @@ table.remove_style(None, lv.PART.ITEMS | lv.STATE.PRESSED)
for i in range(ITEM_CNT):
table.set_cell_value(i, 0, "Item " + str(i+1))
table.align(lv.ALIGN.CENTER, 0, -20);
table.align(lv.ALIGN.CENTER, 0, -20)
# Add an event callback to to apply some custom drawing
table.add_event_cb(draw_event_cb, lv.EVENT.DRAW_PART_END, None)
@@ -93,4 +93,3 @@ label.set_text(str(ITEM_CNT) + " items were created in " + str(elaps) + " ms\n u
#label.set_text(str(ITEM_CNT) + " items were created in " + str(elaps) + " ms")
label.align(lv.ALIGN.BOTTOM_MID, 0, -10)