class ImagePlus —— 显示远程图像
ImagePlus 类继承自 Widgets.Image 类,用于提供处理支持动态更新的图像的附加功能。
MicroPython 应用示例:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from image_plus import ImagePlus 9 10 11title0 = None 12image_plus0 = None 13 14 15def setup(): 16 global title0, image_plus0 17 18 M5.begin() 19 Widgets.fillScreen(0x222222) 20 title0 = Widgets.Title("Image+ CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18) 21 image_plus0 = ImagePlus( 22 "https://static-cdn.m5stack.com/resource/public/assets/aboutus/m5logo2022.png", 23 43, 24 51, 25 True, 26 3000, 27 default_img="res/img/default.png", 28 ) 29 30 image_plus0.setVisible(True) 31 image_plus0.set_update_period(5000) 32 image_plus0.set_update_enable(True) 33 34 35def loop(): 36 global title0, image_plus0 37 M5.update() 38 39 40if __name__ == "__main__": 41 try: 42 setup() 43 while True: 44 loop() 45 except (Exception, KeyboardInterrupt) as e: 46 try: 47 from utility import print_error_msg 48 49 print_error_msg(e) 50 except ImportError: 51 print("please update to latest firmware")
UiFlow2 应用示例
Constructors
- class Widgets.ImagePlus(url, x, y, enable, period, default_img='res/img/default.jpg', parent=None)
创建一个 ImagePlus 对象。它接受以下参数:
url是要获取并显示的图像的 URL。x是图像将要显示的起始 X 轴坐标。y是将显示图像的起始 Y 轴坐标。enable是一个布尔值,用于指示是否启用图像的定期更新。period是当 enable 为 True 时的更新周期,单位为毫秒。default_img是默认图片文件的路径,当 URL 获取失败时将显示该图片。支持的格式为 BMP、JPG 和 PNG。默认值为 “res/img/default.jpg”。parent是绘制图像的图形对象。如果未提供,则将使用默认显示器。
Methods
- ImagePlus.set_update_enable(enable: bool)
启用或禁用图像的周期性更新。接受以下参数:
enable是一个布尔值,用于指示是否应启用更新。
UIFLOW2:





