M5Spinner
M5Spinner 是一个环形上旋转的弧形,通常用于显示有某些操作正在进行中。
UiFlow2 示例
spinner
在 UiFlow2 中打开 core2_spinner_example.m5f2 项目。
本示例演示了一个在环形上旋转的弧形。
UiFlow2 代码块:
示例输出:
None
MicroPython 示例
spinner
本示例演示了一个在环形上旋转的弧形。
MicroPython 代码块:
1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8import m5ui 9import lvgl as lv 10 11 12page0 = None 13spinner0 = None 14 15 16def setup(): 17 global page0, spinner0 18 19 M5.begin() 20 Widgets.setRotation(1) 21 m5ui.init() 22 page0 = m5ui.M5Page(bg_c=0xFFFFFF) 23 spinner0 = m5ui.M5Spinner( 24 x=71, 25 y=81, 26 w=100, 27 h=100, 28 anim_t=10000, 29 angle=180, 30 bg_c=0xE7E3E7, 31 bg_c_indicator=0x2193F3, 32 parent=page0, 33 ) 34 35 page0.screen_load() 36 37 38def loop(): 39 global page0, spinner0 40 M5.update() 41 42 43if __name__ == "__main__": 44 try: 45 setup() 46 while True: 47 loop() 48 except (Exception, KeyboardInterrupt) as e: 49 try: 50 m5ui.deinit() 51 from utility import print_error_msg 52 53 print_error_msg(e) 54 except ImportError: 55 print("please update to latest firmware")
示例输出:
None
API参考
M5Spinner
- class m5ui.spinner.M5Spinner(*args, **kwargs)
基类:
spinner创建一个spinner对象。
- 参数:
UiFlow2 代码块:
None
MicroPython 代码块:
from m5ui import M5Spinner import lvgl as lv m5ui.init() spinner_0 = M5Spinner(x=120, y=80, w=60, h=30, anim_t=1000, angle=180, bg_c=0xE7E3E7, bg_c_indicator=0x0288FB, parent=page0)
- set_flag(flag, value)
在对象上设置标志。如果
value为 True,则添加标志;为 False 时移除标志。UiFlow2 代码块:

MicroPython 代码块:
spinner_0.set_flag(lv.obj.FLAG.HIDDEN, True)
- set_pos(x, y)
设置spinner的位置。
UiFlow2 代码块:

MicroPython 代码块:
spinner_0.set_pos(100, 100)
- set_x(x)
设置spinner的 x 坐标。
- 参数:
x (int) – spinner的 x 坐标。
UiFlow2 代码块:

MicroPython 代码块:
spinner_0.set_x(100)
- set_y(y)
设置spinner的 y 坐标。
- 参数:
y (int) – spinner的 y 坐标。
UiFlow2 代码块:

MicroPython 代码块:
spinner_0.set_y(100)
- set_size(width, height)
设置spinner的尺寸。
UiFlow2 代码块:

MicroPython 代码块:
spinner_0.set_size(100, 50)
- align_to(obj, align, x, y)
将spinner对齐到另一个对象。
UiFlow2 代码块:

MicroPython 代码块:
spinner_0.align_to(page_0, lv.ALIGN.CENTER, 0, 0)
- set_anim_params(anim_t, angle)
设置spinner的动画参数。
UiFlow2 代码块:

MicroPython 代码块:
spinner_0.set_anim_params(1000, 180)


