chore(style): remove the trailing space from all source files (#3188)
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Animation Image
|
||||
Simple Animation Image
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/animimg/lv_example_animimg_1
|
||||
|
||||
@@ -13,10 +13,10 @@ try:
|
||||
except:
|
||||
print("Could not find animimg001.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
anim_imgs[0] = lv.img_dsc_t({
|
||||
'data_size': len(anim001_data),
|
||||
'data': anim001_data
|
||||
'data': anim001_data
|
||||
})
|
||||
|
||||
try:
|
||||
@@ -25,10 +25,10 @@ try:
|
||||
except:
|
||||
print("Could not find animimg002.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
anim_imgs[1] = lv.img_dsc_t({
|
||||
'data_size': len(anim002_data),
|
||||
'data': anim002_data
|
||||
'data': anim002_data
|
||||
})
|
||||
|
||||
try:
|
||||
@@ -37,10 +37,10 @@ try:
|
||||
except:
|
||||
print("Could not find animimg003.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
anim_imgs[2] = lv.img_dsc_t({
|
||||
'data_size': len(anim003_data),
|
||||
'data': anim003_data
|
||||
'data': anim003_data
|
||||
})
|
||||
|
||||
animimg0 = lv.animimg(lv.scr_act())
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
Simple Arc
|
||||
Simple Arc
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/arc/lv_example_arc_1
|
||||
:language: c
|
||||
:description: A simple example to demonstrate the use of an arc.
|
||||
|
||||
Loader with Arc
|
||||
Loader with Arc
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/arc/lv_example_arc_2
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
class ArcLoader():
|
||||
def __init__(self):
|
||||
self.a = 270
|
||||
|
||||
|
||||
def arc_loader_cb(self,tim,arc):
|
||||
# print(tim,arc)
|
||||
self.a += 5
|
||||
@@ -33,5 +33,5 @@ arc_loader = ArcLoader()
|
||||
timer = lv.timer_create_basic()
|
||||
timer.set_period(20)
|
||||
timer.set_cb(lambda src: arc_loader.arc_loader_cb(timer,arc))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
Simple Bar
|
||||
Simple Bar
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/bar/lv_example_bar_1
|
||||
:language: c
|
||||
|
||||
|
||||
Styling a bar
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/bar/lv_example_bar_2
|
||||
:language: c
|
||||
|
||||
|
||||
Temperature meter
|
||||
""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/bar/lv_example_bar_3
|
||||
:language: c
|
||||
|
||||
|
||||
Stripe pattern and range value
|
||||
""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/bar/lv_example_bar_4
|
||||
:language: c
|
||||
|
||||
|
||||
Bar with LTR and RTL base direction
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
@@ -33,4 +33,4 @@ Custom drawer to show the current value
|
||||
|
||||
.. lv_example:: widgets/bar/lv_example_bar_6
|
||||
:language: c
|
||||
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ def get_icon(filename,xres,yres):
|
||||
with open(sdl_filename,'rb') as f:
|
||||
icon_data = f.read()
|
||||
except:
|
||||
print("Could not find image file: " + filename)
|
||||
print("Could not find image file: " + filename)
|
||||
return None
|
||||
|
||||
|
||||
icon_dsc = lv.img_dsc_t(
|
||||
{
|
||||
"header": {"always_zero": 0, "w": xres, "h": yres, "cf": lv.img.CF.TRUE_COLOR_ALPHA},
|
||||
@@ -42,4 +42,4 @@ bar.set_value(90, lv.ANIM.OFF)
|
||||
bar.set_start_value(20, lv.ANIM.OFF)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Buttons
|
||||
Simple Buttons
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/btn/lv_example_btn_1
|
||||
@@ -11,7 +11,7 @@ Styling buttons
|
||||
|
||||
.. lv_example:: widgets/btn/lv_example_btn_2
|
||||
:language: c
|
||||
|
||||
|
||||
Gummy button
|
||||
""""""""""""""""
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ def event_handler(evt):
|
||||
print("Clicked event seen")
|
||||
elif code == lv.EVENT.VALUE_CHANGED:
|
||||
print("Value changed seen")
|
||||
|
||||
|
||||
# create a simple button
|
||||
btn1 = lv.btn(lv.scr_act())
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
|
||||
Simple Button matrix
|
||||
Simple Button matrix
|
||||
""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/btnmatrix/lv_example_btnmatrix_1
|
||||
:language: c
|
||||
|
||||
|
||||
Custom buttons
|
||||
Custom buttons
|
||||
""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/btnmatrix/lv_example_btnmatrix_2
|
||||
:language: c
|
||||
|
||||
|
||||
Pagination
|
||||
Pagination
|
||||
""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/btnmatrix/lv_example_btnmatrix_3
|
||||
|
||||
@@ -12,10 +12,10 @@ try:
|
||||
except:
|
||||
print("Could not find star.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_star_argb = lv.img_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
'data': png_data
|
||||
})
|
||||
|
||||
def event_cb(e):
|
||||
@@ -44,7 +44,7 @@ def event_cb(e):
|
||||
dsc.rect_dsc.bg_color = lv.palette_darken(lv.PALETTE.RED, 3)
|
||||
else:
|
||||
dsc.rect_dsc.bg_color = lv.palette_main(lv.PALETTE.RED)
|
||||
|
||||
|
||||
dsc.label_dsc.color = lv.color_white()
|
||||
elif dsc.id == 3:
|
||||
dsc.label_dsc.opa = lv.OPA.TRANSP # Hide the text if any
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Calendar with header
|
||||
Calendar with header
|
||||
""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/calendar/lv_example_calendar_1
|
||||
|
||||
@@ -5,10 +5,10 @@ def event_handler(evt):
|
||||
if code == lv.EVENT.VALUE_CHANGED:
|
||||
source = evt.get_current_target()
|
||||
date = lv.calendar_date_t()
|
||||
if source.get_pressed_date(date) == lv.RES.OK:
|
||||
if source.get_pressed_date(date) == lv.RES.OK:
|
||||
calendar.set_today_date(date.year, date.month, date.day)
|
||||
print("Clicked date: %02d.%02d.%02d"%(date.day, date.month, date.year))
|
||||
|
||||
|
||||
|
||||
calendar = lv.calendar(lv.scr_act())
|
||||
calendar.set_size(200, 200)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Drawing on the Canvas and rotate
|
||||
Drawing on the Canvas and rotate
|
||||
""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
CANVAS_WIDTH = 50
|
||||
CANVAS_HEIGHT = 50
|
||||
LV_COLOR_CHROMA_KEY = lv.color_hex(0x00ff00)
|
||||
LV_COLOR_CHROMA_KEY = lv.color_hex(0x00ff00)
|
||||
|
||||
def LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h):
|
||||
return int(((w / 8) + 1) * h)
|
||||
@@ -13,7 +13,7 @@ def LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h):
|
||||
|
||||
#
|
||||
# Create a transparent canvas with Chroma keying and indexed color format (palette).
|
||||
#
|
||||
#
|
||||
|
||||
# Create a button to better see the transparency
|
||||
btn=lv.btn(lv.scr_act())
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
|
||||
Line Chart
|
||||
Line Chart
|
||||
""""""""""
|
||||
|
||||
.. lv_example:: widgets/chart/lv_example_chart_1
|
||||
:language: c
|
||||
|
||||
|
||||
Faded area line chart with custom division lines
|
||||
|
||||
|
||||
Faded area line chart with custom division lines
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/chart/lv_example_chart_2
|
||||
:language: c
|
||||
|
||||
|
||||
Axis ticks and labels with scrolling
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/chart/lv_example_chart_3
|
||||
:language: c
|
||||
|
||||
|
||||
Show the value of the pressed points
|
||||
""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/chart/lv_example_chart_4
|
||||
:language: c
|
||||
|
||||
|
||||
Display 1000 data points with zooming and scrolling
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/chart/lv_example_chart_5
|
||||
:language: c
|
||||
|
||||
|
||||
Show cursor on the clicked point
|
||||
"""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/chart/lv_example_chart_6
|
||||
:language: c
|
||||
|
||||
|
||||
Scatter chart
|
||||
"""""""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
def draw_event_cb(e):
|
||||
|
||||
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
|
||||
if dsc.part == lv.PART.TICKS and dsc.id == lv.chart.AXIS.PRIMARY_X:
|
||||
if dsc.part == lv.PART.TICKS and dsc.id == lv.chart.AXIS.PRIMARY_X:
|
||||
month = ["Jan", "Febr", "March", "Apr", "May", "Jun", "July", "Aug", "Sept", "Oct", "Nov", "Dec"]
|
||||
# dsc.text is defined char text[16], I must therefore convert the Python string to a byte_array
|
||||
dsc.text = bytes(month[dsc.value],"ascii")
|
||||
dsc.text = bytes(month[dsc.value],"ascii")
|
||||
#
|
||||
# Add ticks and labels to the axis and demonstrate scrolling
|
||||
#
|
||||
|
||||
@@ -18,7 +18,7 @@ def event_cb(e):
|
||||
chart.get_point_pos_by_id(series[i], id, p)
|
||||
value = series_points[i][id]
|
||||
buf = lv.SYMBOL.DUMMY + "$" + str(value)
|
||||
|
||||
|
||||
draw_rect_dsc = lv.draw_rect_dsc_t()
|
||||
draw_rect_dsc.init()
|
||||
draw_rect_dsc.bg_color = lv.color_black()
|
||||
@@ -26,7 +26,7 @@ def event_cb(e):
|
||||
draw_rect_dsc.radius = 3
|
||||
draw_rect_dsc.bg_img_src = buf
|
||||
draw_rect_dsc.bg_img_recolor = lv.color_white()
|
||||
|
||||
|
||||
a = lv.area_t()
|
||||
coords = lv.area_t()
|
||||
chart.get_coords(coords)
|
||||
@@ -34,14 +34,14 @@ def event_cb(e):
|
||||
a.x2 = coords.x1 + p.x + 20
|
||||
a.y1 = coords.y1 + p.y - 30
|
||||
a.y2 = coords.y1 + p.y - 10
|
||||
|
||||
|
||||
clip_area = lv.area_t.__cast__(e.get_param())
|
||||
lv.draw_rect(a, clip_area, draw_rect_dsc)
|
||||
|
||||
|
||||
elif code == lv.EVENT.RELEASED:
|
||||
chart.invalidate()
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
# Add ticks and labels to the axis and demonstrate scrolling
|
||||
#
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def slider_y_event_cb(e):
|
||||
# Display 1000 data points with zooming and scrolling.
|
||||
# See how the chart changes drawing mode (draw only vertical lines) when
|
||||
# the points get too crowded.
|
||||
|
||||
|
||||
# Create a chart
|
||||
chart = lv.chart(lv.scr_act())
|
||||
chart.set_size(200, 150)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ExampleChart_6():
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.last_id = -1
|
||||
#
|
||||
@@ -9,21 +9,21 @@ class ExampleChart_6():
|
||||
chart = lv.chart(lv.scr_act())
|
||||
chart.set_size(200, 150)
|
||||
chart.align(lv.ALIGN.CENTER, 0, -10)
|
||||
|
||||
|
||||
chart.set_axis_tick(lv.chart.AXIS.PRIMARY_Y, 10, 5, 6, 5, True, 40)
|
||||
chart.set_axis_tick(lv.chart.AXIS.PRIMARY_X, 10, 5, 10, 1, True, 30)
|
||||
|
||||
|
||||
chart.add_event_cb(self.event_cb, lv.EVENT.ALL, None)
|
||||
chart.refresh_ext_draw_size()
|
||||
|
||||
|
||||
self.cursor = chart.add_cursor(lv.palette_main(lv.PALETTE.BLUE), lv.DIR.LEFT | lv.DIR.BOTTOM)
|
||||
|
||||
|
||||
self.ser = chart.add_series(lv.palette_main(lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y)
|
||||
|
||||
self.ser_p = []
|
||||
for i in range(10):
|
||||
self.ser_p.append(lv.rand(10,90))
|
||||
self.ser.y_points = self.ser_p
|
||||
self.ser.y_points = self.ser_p
|
||||
|
||||
newser = chart.get_series_next(None)
|
||||
# print("length of data points: ",len(newser.points))
|
||||
@@ -32,8 +32,8 @@ class ExampleChart_6():
|
||||
label = lv.label(lv.scr_act())
|
||||
label.set_text("Click on a point")
|
||||
label.align_to(chart, lv.ALIGN.OUT_TOP_MID, 0, -5)
|
||||
|
||||
|
||||
|
||||
|
||||
def event_cb(self,e):
|
||||
|
||||
code = e.get_code()
|
||||
@@ -46,7 +46,7 @@ class ExampleChart_6():
|
||||
p = lv.point_t()
|
||||
chart.get_point_pos_by_id(self.ser, self.last_id, p)
|
||||
chart.set_cursor_point(self.cursor, None, self.last_id)
|
||||
|
||||
|
||||
elif code == lv.EVENT.DRAW_PART_END:
|
||||
# print("EVENT.DRAW_PART_END")
|
||||
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
|
||||
@@ -57,25 +57,25 @@ class ExampleChart_6():
|
||||
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]
|
||||
|
||||
|
||||
# print("value: ",v)
|
||||
value_txt = str(v)
|
||||
size = lv.point_t()
|
||||
lv.txt_get_size(size, value_txt, lv.font_default(), 0, 0, lv.COORD.MAX, lv.TEXT_FLAG.NONE)
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
lv.draw_rect(a, dsc.clip_area, draw_rect_dsc)
|
||||
|
||||
|
||||
draw_label_dsc = lv.draw_label_dsc_t()
|
||||
draw_label_dsc.init()
|
||||
draw_label_dsc.color = lv.color_white()
|
||||
|
||||
@@ -12,7 +12,7 @@ def draw_event_cb(e):
|
||||
# print("cnt: ",cnt)
|
||||
# Make older value more transparent
|
||||
dsc.rect_dsc.bg_opa = (lv.OPA.COVER * dsc.id) // (cnt - 1)
|
||||
|
||||
|
||||
# Make smaller values blue, higher values red
|
||||
# x_array = chart.get_x_array(ser)
|
||||
# y_array = chart.get_y_array(ser)
|
||||
@@ -23,11 +23,11 @@ def draw_event_cb(e):
|
||||
# print("p_act", p_act)
|
||||
x_opa = (x_array[p_act] * lv.OPA._50) // 200
|
||||
y_opa = (y_array[p_act] * lv.OPA._50) // 1000
|
||||
|
||||
|
||||
dsc.rect_dsc.bg_color = lv.palette_main(lv.PALETTE.RED).color_mix(
|
||||
lv.palette_main(lv.PALETTE.BLUE),
|
||||
x_opa + y_opa)
|
||||
|
||||
|
||||
def add_data(timer,chart):
|
||||
# print("add_data")
|
||||
x = lv.rand(0,200)
|
||||
@@ -38,7 +38,7 @@ def add_data(timer,chart):
|
||||
x_array.append(x)
|
||||
y_array.pop(0)
|
||||
y_array.append(y)
|
||||
|
||||
|
||||
#
|
||||
# A scatter chart
|
||||
#
|
||||
@@ -66,7 +66,7 @@ y_array = []
|
||||
for i in range(50):
|
||||
x_array.append(lv.rand(0, 200))
|
||||
y_array.append(lv.rand(0, 1000))
|
||||
|
||||
|
||||
ser.x_points = x_array
|
||||
ser.y_points = y_array
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ def lv_example_chart_8():
|
||||
stacked_area_chart.obj.set_div_line_count(5, 7)
|
||||
stacked_area_chart.obj.add_event_cb( draw_event_cb, lv.EVENT.DRAW_PART_BEGIN, None)
|
||||
|
||||
# Set range to 0 to 100 for percentages. Draw ticks
|
||||
# Set range to 0 to 100 for percentages. Draw ticks
|
||||
stacked_area_chart.obj.set_range(lv.chart.AXIS.PRIMARY_Y,0,100)
|
||||
stacked_area_chart.obj.set_axis_tick(lv.chart.AXIS.PRIMARY_Y, 3, 0, 5, 1, True, 30)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
def event_handler(e):
|
||||
code = e.get_code()
|
||||
obj = e.get_target()
|
||||
if code == lv.EVENT.VALUE_CHANGED:
|
||||
if code == lv.EVENT.VALUE_CHANGED:
|
||||
option = " "*10 # should be large enough to store the option
|
||||
obj.get_selected_str(option, len(option))
|
||||
# .strip() removes trailing spaces
|
||||
|
||||
@@ -12,10 +12,10 @@ try:
|
||||
except:
|
||||
print("Could not find img_caret_down.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_caret_down_argb = lv.img_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
'data': png_data
|
||||
})
|
||||
|
||||
def event_cb(e):
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
|
||||
Image from variable and symbol
|
||||
Image from variable and symbol
|
||||
"""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/img/lv_example_img_1
|
||||
:language: c
|
||||
|
||||
|
||||
Image recoloring
|
||||
Image recoloring
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/img/lv_example_img_2
|
||||
:language: c
|
||||
|
||||
|
||||
Rotate and zoom
|
||||
Rotate and zoom
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/img/lv_example_img_3
|
||||
:language: c
|
||||
|
||||
|
||||
Image offset and styling
|
||||
""""""""""""""""""""""""
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ try:
|
||||
except:
|
||||
print("Could not find img_cogwheel_argb.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_cogwheel_argb = lv.img_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
'data': png_data
|
||||
})
|
||||
|
||||
img1 = lv.img(lv.scr_act())
|
||||
|
||||
@@ -16,10 +16,10 @@ try:
|
||||
except:
|
||||
print("Could not find img_cogwheel_argb.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_cogwheel_argb = lv.img_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
'data': png_data
|
||||
})
|
||||
|
||||
def create_slider(color):
|
||||
@@ -37,7 +37,7 @@ def slider_event_cb(e):
|
||||
intense = intense_slider.get_value()
|
||||
img1.set_style_img_recolor_opa(intense, 0)
|
||||
img1.set_style_img_recolor(color, 0)
|
||||
|
||||
|
||||
#
|
||||
# Demonstrate runtime image re-coloring
|
||||
#
|
||||
|
||||
@@ -16,10 +16,10 @@ try:
|
||||
except:
|
||||
print("Could not find img_cogwheel_argb.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_cogwheel_argb = lv.img_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
'data': png_data
|
||||
})
|
||||
|
||||
def set_angle(img, v):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from imagetools import get_png_info, open_png
|
||||
|
||||
def ofs_y_anim(img, v):
|
||||
def ofs_y_anim(img, v):
|
||||
img.set_offset_y(v)
|
||||
# print(img,v)
|
||||
|
||||
|
||||
# Register PNG image decoder
|
||||
decoder = lv.img.decoder_create()
|
||||
decoder.info_cb = get_png_info
|
||||
@@ -16,10 +16,10 @@ try:
|
||||
except:
|
||||
print("Could not find img_skew_strip.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_skew_strip = lv.img_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
'data': png_data
|
||||
})
|
||||
|
||||
#
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Image button
|
||||
Simple Image button
|
||||
"""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/imgbtn/lv_example_imgbtn_1
|
||||
|
||||
@@ -12,10 +12,10 @@ try:
|
||||
except:
|
||||
print("Could not find imgbtn_left.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
imgbtn_left_dsc = lv.img_dsc_t({
|
||||
'data_size': len(imgbtn_left_data),
|
||||
'data': imgbtn_left_data
|
||||
'data': imgbtn_left_data
|
||||
})
|
||||
|
||||
try:
|
||||
@@ -24,10 +24,10 @@ try:
|
||||
except:
|
||||
print("Could not find imgbtn_mid.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
imgbtn_mid_dsc = lv.img_dsc_t({
|
||||
'data_size': len(imgbtn_mid_data),
|
||||
'data': imgbtn_mid_data
|
||||
'data': imgbtn_mid_data
|
||||
})
|
||||
|
||||
try:
|
||||
@@ -36,10 +36,10 @@ try:
|
||||
except:
|
||||
print("Could not find imgbtn_right.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
imgbtn_right_dsc = lv.img_dsc_t({
|
||||
'data_size': len(imgbtn_right_data),
|
||||
'data': imgbtn_right_data
|
||||
'data': imgbtn_right_data
|
||||
})
|
||||
|
||||
# Create a transition animation on width transformation and recolor.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Keyboard with text area
|
||||
Keyboard with text area
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/keyboard/lv_example_keyboard_1
|
||||
|
||||
@@ -8,7 +8,7 @@ def ta_event_cb(e,kb):
|
||||
if code == lv.EVENT.DEFOCUSED:
|
||||
kb.set_textarea(None)
|
||||
kb.add_flag(lv.obj.FLAG.HIDDEN)
|
||||
|
||||
|
||||
# Create a keyboard to use it with one of the text areas
|
||||
kb = lv.keyboard(lv.scr_act())
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ try:
|
||||
except:
|
||||
font_montserrat_16 = lv.font_load("S:../../assets/font/montserrat-16.fnt")
|
||||
ltr_label.set_style_text_font(font_montserrat_16, 0)
|
||||
|
||||
|
||||
ltr_label.set_width(310)
|
||||
ltr_label.align(lv.ALIGN.TOP_LEFT, 5, 5)
|
||||
|
||||
@@ -30,7 +30,7 @@ font_simsun_16_cjk = lv.font_load("S:../../assets/font/lv_font_simsun_16_cjk.fnt
|
||||
|
||||
cz_label = lv.label(lv.scr_act())
|
||||
cz_label.set_style_text_font(font_simsun_16_cjk, 0)
|
||||
cz_label.set_text("嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。")
|
||||
cz_label.set_text("嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。")
|
||||
cz_label.set_width(310)
|
||||
cz_label.align(lv.ALIGN.BOTTOM_LEFT, 5, -5)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Line
|
||||
Simple Line
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/line/lv_example_line_1
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Create an array for the points of the line
|
||||
line_points = [ {"x":5, "y":5},
|
||||
{"x":70, "y":70},
|
||||
{"x":120, "y":10},
|
||||
{"x":180, "y":60},
|
||||
line_points = [ {"x":5, "y":5},
|
||||
{"x":70, "y":70},
|
||||
{"x":120, "y":10},
|
||||
{"x":180, "y":60},
|
||||
{"x":240, "y":10}]
|
||||
|
||||
# Create style
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
Simple List
|
||||
Simple List
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/list/lv_example_list_1
|
||||
:language: c
|
||||
|
||||
|
||||
Sorting a List using up and down buttons
|
||||
Sorting a List using up and down buttons
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/list/lv_example_list_2
|
||||
|
||||
@@ -81,7 +81,7 @@ def event_handler_swap(evt):
|
||||
global list1
|
||||
code = evt.get_code()
|
||||
obj = evt.get_target()
|
||||
if code == lv.EVENT.CLICKED:
|
||||
if code == lv.EVENT.CLICKED:
|
||||
cnt = list1.get_child_cnt()
|
||||
for i in range(100):
|
||||
if cnt > 1:
|
||||
@@ -89,7 +89,7 @@ def event_handler_swap(evt):
|
||||
obj.move_to_index(urandom.getrandbits(32) % cnt)
|
||||
if currentButton != None:
|
||||
currentButton.scroll_to_view(lv.ANIM.ON)
|
||||
|
||||
|
||||
#Create a list with buttons that can be sorted
|
||||
list1 = lv.list(lv.scr_act())
|
||||
list1.set_size(lv.pct(60), lv.pct(100))
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
Simple Menu
|
||||
Simple Menu
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/menu/lv_example_menu_1
|
||||
:language: c
|
||||
|
||||
|
||||
Simple Menu with root btn
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/menu/lv_example_menu_2
|
||||
:language: c
|
||||
|
||||
|
||||
Simple Menu with custom header
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
@@ -22,7 +22,7 @@ Simple Menu with floating btn to add new menu page
|
||||
|
||||
.. lv_example:: widgets/menu/lv_example_menu_4
|
||||
:language: c
|
||||
|
||||
|
||||
Complex Menu
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ def back_event_handler(e):
|
||||
if menu.back_btn_is_root(obj):
|
||||
mbox1 = lv.msgbox(lv.scr_act(), "Hello", "Root back btn click.", None, True)
|
||||
mbox1.center()
|
||||
|
||||
|
||||
# Create a menu object
|
||||
menu = lv.menu(lv.scr_act())
|
||||
menu.set_mode_root_back_btn(lv.menu.ROOT_BACK_BTN.ENABLED)
|
||||
|
||||
@@ -16,10 +16,10 @@ try:
|
||||
except:
|
||||
print("Could not find img_hand_min.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_hand_min_dsc = lv.img_dsc_t({
|
||||
'data_size': len(img_hand_min_data),
|
||||
'data': img_hand_min_data
|
||||
'data': img_hand_min_data
|
||||
})
|
||||
|
||||
# Create an image from the png file
|
||||
@@ -29,10 +29,10 @@ try:
|
||||
except:
|
||||
print("Could not find img_hand_hour.png")
|
||||
sys.exit()
|
||||
|
||||
|
||||
img_hand_hour_dsc = lv.img_dsc_t({
|
||||
'data_size': len(img_hand_hour_data),
|
||||
'data': img_hand_hour_data
|
||||
'data': img_hand_hour_data
|
||||
})
|
||||
|
||||
def set_value(indic, v):
|
||||
@@ -78,6 +78,6 @@ a2.init()
|
||||
a2.set_var(indic_hour)
|
||||
a2.set_time(24000) # 24 sec for 1 turn of the hour hand
|
||||
a2.set_values(0, 60)
|
||||
a2.set_custom_exec_cb(lambda a2,val: set_value(indic_hour,val))
|
||||
a2.set_custom_exec_cb(lambda a2,val: set_value(indic_hour,val))
|
||||
lv.anim_t.start(a2)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Message box
|
||||
Simple Message box
|
||||
"""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/msgbox/lv_example_msgbox_1
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
Base objects with custom styles
|
||||
Base objects with custom styles
|
||||
""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/obj/lv_example_obj_1
|
||||
:language: c
|
||||
|
||||
Make an object draggable
|
||||
|
||||
Make an object draggable
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/obj/lv_example_obj_2
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
Simple Roller
|
||||
Simple Roller
|
||||
""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/roller/lv_example_roller_1
|
||||
:language: c
|
||||
|
||||
|
||||
Styling the roller
|
||||
""""""""""""""""""
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import fs_driver
|
||||
def event_handler(e):
|
||||
code = e.get_code()
|
||||
obj = e.get_target()
|
||||
if code == lv.EVENT.VALUE_CHANGED:
|
||||
if code == lv.EVENT.VALUE_CHANGED:
|
||||
option = " "*10
|
||||
obj.get_selected_str(option, len(option))
|
||||
print("Selected value: %s\n" + option.strip())
|
||||
@@ -25,7 +25,7 @@ except:
|
||||
print("montserrat-22 not enabled in lv_conf.h, dynamically loading the font")
|
||||
font_montserrat_22 = lv.font_load("S:" + "../../assets/font/montserrat-22.fnt")
|
||||
style_sel.set_text_font(font_montserrat_22)
|
||||
|
||||
|
||||
opts = "\n".join(["1","2","3","4","5","6","7","8","9","10"])
|
||||
|
||||
# A roller on the left with left aligned text, and custom width
|
||||
|
||||
@@ -6,23 +6,23 @@ class Lv_Roller_3():
|
||||
def __init__(self):
|
||||
self.mask_top_id = -1
|
||||
self.mask_bottom_id = -1
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
# Add a fade mask to roller.
|
||||
#
|
||||
style = lv.style_t()
|
||||
style.init()
|
||||
style.set_bg_color(lv.color_black())
|
||||
style.set_text_color(lv.color_white())
|
||||
|
||||
|
||||
lv.scr_act().add_style(style, 0)
|
||||
|
||||
|
||||
roller1 = lv.roller(lv.scr_act())
|
||||
roller1.add_style(style, 0)
|
||||
roller1.set_style_border_width(0, 0)
|
||||
roller1.set_style_pad_all(0, 0)
|
||||
roller1.set_style_bg_opa(lv.OPA.TRANSP, lv.PART.SELECTED)
|
||||
|
||||
|
||||
#if LV_FONT_MONTSERRAT_22
|
||||
# lv_obj_set_style_text_font(roller1, &lv_font_montserrat_22, LV_PART_SELECTED);
|
||||
#endif
|
||||
@@ -34,7 +34,7 @@ class Lv_Roller_3():
|
||||
print("montserrat-22 not enabled in lv_conf.h, dynamically loading the font")
|
||||
font_montserrat_22 = lv.font_load("S:" + "../../assets/font/montserrat-22.fnt")
|
||||
roller1.set_style_text_font(font_montserrat_22,lv.PART.SELECTED)
|
||||
|
||||
|
||||
roller1.set_options("\n".join([
|
||||
"January",
|
||||
"February",
|
||||
@@ -62,27 +62,27 @@ class Lv_Roller_3():
|
||||
e.set_cover_res(lv.COVER_RES.MASKED)
|
||||
|
||||
elif code == lv.EVENT.DRAW_MAIN_BEGIN:
|
||||
# add mask
|
||||
# add mask
|
||||
font = obj.get_style_text_font(lv.PART.MAIN)
|
||||
line_space = obj.get_style_text_line_space(lv.PART.MAIN)
|
||||
font_h = font.get_line_height()
|
||||
|
||||
|
||||
roller_coords = lv.area_t()
|
||||
obj.get_coords(roller_coords)
|
||||
|
||||
|
||||
rect_area = lv.area_t()
|
||||
rect_area.x1 = roller_coords.x1
|
||||
rect_area.x2 = roller_coords.x2
|
||||
rect_area.y1 = roller_coords.y1
|
||||
rect_area.y2 = roller_coords.y1 + (obj.get_height() - font_h - line_space) // 2
|
||||
|
||||
|
||||
fade_mask_top = lv.draw_mask_fade_param_t()
|
||||
fade_mask_top.init(rect_area, lv.OPA.TRANSP, rect_area.y1, lv.OPA.COVER, rect_area.y2)
|
||||
self.mask_top_id = lv.draw_mask_add(fade_mask_top,None)
|
||||
|
||||
|
||||
rect_area.y1 = rect_area.y2 + font_h + line_space - 1
|
||||
rect_area.y2 = roller_coords.y2
|
||||
|
||||
|
||||
fade_mask_bottom = lv.draw_mask_fade_param_t()
|
||||
fade_mask_bottom.init(rect_area, lv.OPA.COVER, rect_area.y1, lv.OPA.TRANSP, rect_area.y2)
|
||||
self.mask_bottom_id = lv.draw_mask_add(fade_mask_bottom, None)
|
||||
@@ -95,5 +95,5 @@ class Lv_Roller_3():
|
||||
lv.draw_mask_remove_id(self.mask_bottom_id)
|
||||
self.mask_top_id = -1
|
||||
self.mask_bottom_id = -1
|
||||
|
||||
|
||||
roller3 = Lv_Roller_3()
|
||||
|
||||
@@ -10,11 +10,11 @@ Slider with custom style
|
||||
|
||||
.. lv_example:: widgets/slider/lv_example_slider_2
|
||||
:language: c
|
||||
|
||||
|
||||
Slider with extended drawer
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/slider/lv_example_slider_3
|
||||
:language: c
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#
|
||||
#
|
||||
# A default slider with a label displaying the current value
|
||||
#
|
||||
def slider_event_cb(e):
|
||||
|
||||
@@ -5,7 +5,7 @@ def slider_event_cb(e):
|
||||
# Provide some extra space for the value
|
||||
if code == lv.EVENT.REFR_EXT_DRAW_SIZE:
|
||||
e.set_ext_draw_size(50)
|
||||
|
||||
|
||||
elif code == lv.EVENT.DRAW_PART_END:
|
||||
# print("DRAW_PART_END")
|
||||
dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Spinbox
|
||||
Simple Spinbox
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/spinbox/lv_example_spinbox_1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple spinner
|
||||
Simple spinner
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/spinner/lv_example_spinner_1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Switch
|
||||
Simple Switch
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/switch/lv_example_switch_1
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
|
||||
Simple table
|
||||
Simple table
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/table/lv_example_table_1
|
||||
:language: c
|
||||
|
||||
|
||||
Lightweighted list from table
|
||||
""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ def draw_event_cb(e):
|
||||
rect_dsc.bg_color = lv.theme_get_color_primary(obj)
|
||||
else:
|
||||
rect_dsc.bg_color = lv.palette_lighten(lv.PALETTE.GREY, 2)
|
||||
|
||||
|
||||
rect_dsc.radius = lv.RADIUS.CIRCLE
|
||||
|
||||
sw_area = lv.area_t()
|
||||
@@ -26,9 +26,9 @@ def draw_event_cb(e):
|
||||
sw_area.y1 = dsc.draw_area.y1 + dsc.draw_area.get_height() // 2 - 10
|
||||
sw_area.y2 = sw_area.y1 + 20
|
||||
dsc.draw_ctx.rect(rect_dsc, sw_area)
|
||||
|
||||
|
||||
rect_dsc.bg_color = lv.color_white()
|
||||
|
||||
|
||||
if chk:
|
||||
sw_area.x2 -= 2
|
||||
sw_area.x1 = sw_area.x2 - 16
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple Tabview
|
||||
Simple Tabview
|
||||
"""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/tabview/lv_example_tabview_1
|
||||
|
||||
@@ -4,14 +4,14 @@ Simple Text area
|
||||
|
||||
.. lv_example:: widgets/textarea/lv_example_textarea_1
|
||||
:language: c
|
||||
|
||||
|
||||
Text area with password field
|
||||
|
||||
|
||||
Text area with password field
|
||||
"""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/textarea/lv_example_textarea_2
|
||||
:language: c
|
||||
|
||||
|
||||
Text auto-formatting
|
||||
"""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ btnm_map = ["1", "2", "3", "\n",
|
||||
"4", "5", "6", "\n",
|
||||
"7", "8", "9", "\n",
|
||||
lv.SYMBOL.BACKSPACE, "0", lv.SYMBOL.NEW_LINE, ""]
|
||||
|
||||
|
||||
btnm = lv.btnmatrix(lv.scr_act())
|
||||
btnm.set_size(200, 150)
|
||||
btnm.align(lv.ALIGN.BOTTOM_MID, 0, -10)
|
||||
|
||||
@@ -14,7 +14,7 @@ def ta_event_cb(e):
|
||||
rest = txt[colon_pos:]
|
||||
if len(rest) > 3:
|
||||
ta.del_char()
|
||||
|
||||
|
||||
if len(txt) < 2:
|
||||
return
|
||||
if ":" in txt:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Tileview with content
|
||||
Tileview with content
|
||||
"""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/tileview/lv_example_tileview_1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
Simple window
|
||||
Simple window
|
||||
"""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/win/lv_example_win_1
|
||||
|
||||
@@ -27,7 +27,7 @@ scrollable.
|
||||
|
||||
We need
|
||||
quite some text
|
||||
and we will
|
||||
and we will
|
||||
even put
|
||||
some more
|
||||
text to be
|
||||
|
||||
Reference in New Issue
Block a user