Skip to content

lvglext_ 模块

lvgl的扩展库

lvgl的字体管理

class pixfont

static load(filename: str, size: int, style: int) -> str

加载字体,支持TTF和lvgl自家的pixel font字体

name: 字体文件名(路径),也可以是字体所在flash partition的名称 size: 字体大小,如果是pixel font字体则此大小可以为0,因为字体文件中存储了字体大小 style: 0-normal, 1-bold, 2-italic, 3-bold italic

参数类型说明
filenamestr
sizeint
styleint
  • 返回: str

static unload(font: pointer) -> str

卸载由load函数加载的字体

font: 字体句柄

参数类型说明
fontpointer
  • 返回: str
C++ 映射 lvext_delete_font

static set_default(font: pointer) -> str

设置lvgl默认字体

font: 字体句柄

参数类型说明
fontpointer
  • 返回: str
C++ 映射 lvext_set_default_font

EAF格式组件

static __init__(parent: instance) -> instance

参数类型说明
parentinstance
  • 返回: instance
C++ 映射 lv_eaf_create

set_src(src: str) -> None

参数类型说明
srcstr
  • 返回: None

restart() -> None

  • 返回: None

pause() -> None

  • 返回: None

resume() -> None

  • 返回: None

is_loaded() -> bool

  • 返回: bool
C++ 映射 lv_eaf_is_loaded

set_loop_count(count: int) -> None

参数类型说明
countint
  • 返回: None

get_loop_count() -> int

  • 返回: int
C++ 映射 lv_eaf_get_loop_count

get_total_frames() -> int

  • 返回: int
C++ 映射 lv_eaf_get_total_frames

get_current_frame() -> int

  • 返回: int
C++ 映射 lv_eaf_get_current_frame

set_frame_delay(delay: uint) -> None

参数类型说明
delayuint
  • 返回: None

get_frame_delay() -> uint

  • 返回: uint
C++ 映射 lv_eaf_get_frame_delay

set_loop_enabled(enabled: bool) -> None

参数类型说明
enabledbool
  • 返回: None

get_loop_enabled() -> bool

C MAP_LV_OBJ_CLASS(&lv_eaf_class, eaf)

  • 返回: bool
C++ 映射 lv_eaf_get_loop_enabled

static __init__(parent: instance, width: int, height: int, path: str) -> instance

参数类型说明
parentinstance
widthint
heightint
pathstr
  • 返回: instance
C++ 映射 lv_rlottie_create_from_file

set_play_mode(mode: uint) -> None

参数类型说明
modeuint
  • 返回: None

set_current_frame(frame: uint) -> None

参数类型说明
frameuint
  • 返回: None

get_total_frames() -> uint

  • 返回: uint
C++ 映射 lv_rlottie_get_total_frames

get_current_frame() -> uint

C MAP_LV_OBJ_CLASS(&lv_rlottie_class, rlottie)

  • 返回: uint
C++ 映射 lv_rlottie_get_current_frame

SVG图像组件

static __init__(parent: instance, dpi: float, width: int, height: int, path: str) -> instance

创建SVG图像组件

parent: 父组件 dpi: SVG渲染的分辨率
width: SVG渲染出来的图像的宽度,0表示使用SVG文件中的宽度 height: SVG渲染出来的图像的高度,0表示使用SVG文件中的高度 path: SVG文件路径

参数类型说明
parentinstance
dpifloat
widthint
heightint
pathstr
  • 返回: instance
C++ 映射 lv_svg_create_from_file

本平台自定义组件:卡片轮播

static __init__(parent: instance, maxcards: int, configs: pointer) -> str

创建卡片轮播组件

parent: 父组件 maxcards: 最多可添加的卡片数量,实际添加数不能超过这个预分配数值 configs: 扩展配置,可以没有,如果存在,则必须是dict格式,格式如下: { 箭头区域宽度(左右滑动时就是箭头区的宽度,上下滑动时就是箭头区的高度) "arrowArea": 20, 卡片与外部容器之间的边框内边距 "padBorder": 0, 卡片圆角半径 "cardRadius": 10, 滑动动画时长(单位通常为 ms) "animTimeSwipe": 300, 基础变换值(常用于缩放、位移或动画基准值),也就是动画从这个数值开始或结束于此 "transformBase": 128, 阴影大小 "shadowSize": 20, 是否为垂直布局(False 为水平布局,不指定则为True) "vertical": True, 翻页后卡片“就绪”的回调 "pageReadyCallback": function(slider, pageId), 翻页后缓动动画结束,卡片进入稳定状态(停止滚动/动画结束)后的回调 "pageStableCallback": function(slider, pageId), 卡片开始拖拽时的回调 "pageBeginDrag": function(slider, pageId), 结束拖拽时的回调 "pageEndDrag": function(slider, pageId), }

参数类型说明
parentinstance
maxcardsint
configspointer
  • 返回: str
C++ 映射 CardSlider__init__

add_card(image_path: str) -> str

添加卡片

image_path: 卡片的图片路径,其实这个参数也可以是一个lv_img_t组件,非img组件没有测试过 return: 返回卡片组件(lv_obj_t)

参数类型说明
image_pathstr
  • 返回: str

get_arrow(is_previous: bool) -> str

获取创建的箭头组件,但如果指定箭头组件的区域大小为0则不会创建箭头创建

is_previous: 为True时,返回箭头为left/up方向的,否则为right/down方向的 return: 箭头组件(lv_obj_t)

参数类型说明
is_previousbool
  • 返回: str

insert_card(index: int, image_path: str) -> str

在指定位置插入一张卡片,和add_card方法一样,但可以指定插入位置

index: 插入位置,0表示第一个位置,-1表示最后一个位置 image_path: 卡片的图片路径,其实这个参数也可以是一个lv_img_t组件,非img组件没有测试过 return: 返回卡片组件(lv_obj_t)

参数类型说明
indexint
image_pathstr
  • 返回: str

flip(forward_flip: bool) -> str

卡片向前或向后翻页

forward_flip: 为True时,向前翻页,否则向后翻页

参数类型说明
forward_flipbool
  • 返回: str
C++ 映射 CardSlider_flip

remove_card(index: int) -> str

移除卡片

index: 移除卡片的位置。这是真实的位置值,不要使用负数来表示从后向前取值

参数类型说明
indexint
  • 返回: str
C++ 映射 CardSlider_remove_card

get_index() -> str

获取当前卡片的索引

return: 当前卡片的索引

  • 返回: str

set_index(index: int) -> str

设置当前卡片的索引

index: 设置的索引也就是页码

参数类型说明
indexint
  • 返回: str
C++ 映射 CardSlider_set_index

get_card(index: int) -> str

获取指定索引的卡片组件

index: 卡片索引也就是页码

参数类型说明
indexint
  • 返回: str

get_inner_size() -> str

获取卡片轮播组件的内部大小

return: 返回内部大小,为2个元素的tuple,第一个元素为宽,第二个元素为高

  • 返回: str

本平台自定义组件:滑动翻页磁贴

static __init__(parent: instance, width: int, height: int, configs: dict) -> str

参数类型说明
parentinstance
widthint
heightint
configsdict
  • 返回: str
C++ 映射 Tilemagnet__init__

add_page(rows: int, cols: int) -> str

参数类型说明
rowsint
colsint
  • 返回: str

get_page(rows: int, cols: int) -> str

参数类型说明
rowsint
colsint
  • 返回: str

add_block(pageid: int, block_obj: instance, xpos: int, ypos: int) -> str

参数类型说明
pageidint
block_objinstance
xposint
yposint
  • 返回: str

get_block(pageid: int, block_index: int) -> str

参数类型说明
pageidint
block_indexint
  • 返回: str

calc_block_pos(width: int, height: int) -> str

参数类型说明
widthint
heightint
  • 返回: str

calc_block_size(pageid: int, width: int, height: int) -> str

参数类型说明
pageidint
widthint
heightint
  • 返回: str

calc_block_pos_size(x: int, y: int, width: int, height: int) -> str

参数类型说明
xint
yint
widthint
heightint
  • 返回: str

remove_block(pageid: int, block_obj: instance) -> str

参数类型说明
pageidint
block_objinstance
  • 返回: str
C++ 映射 Tilemagnet_remove_block

remove_page(pageid: int) -> str

参数类型说明
pageidint
  • 返回: str
C++ 映射 Tilemagnet_remove_page

now_page_id() -> str

  • 返回: str

total_pages() -> str

  • 返回: str

set_lock(lock_it: bool) -> str

参数类型说明
lock_itbool
  • 返回: str
C++ 映射 Tilemagnet_set_lock

set_show_page_id(pageid: int) -> str

参数类型说明
pageidint
  • 返回: str
C++ 映射 Tilemagnet_set_show_page_id

get_child() -> str

C MAP_LV_OBJ_CLASS(&lv_tilemagnet_class, tilemagnet)

  • 返回: str

基于 llpython ESP 平台构建