class Image —— 显示图像。
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 * 8 9 10image0 = None 11title0 = None 12 13 14def setup(): 15 global image0, title0 16 17 M5.begin() 18 Widgets.fillScreen(0x222222) 19 image0 = Widgets.Image("res/img/SCR-20240902-itcy.png", 71, 64) 20 title0 = Widgets.Title("Image CoreS3 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18) 21 22 image0.setImage("res/img/default.png") 23 image0.setImage("res/img/SCR-20240902-itcy.png") 24 image0.setCursor(x=0, y=0) 25 image0.setVisible(True) 26 27 28def loop(): 29 global image0, title0 30 M5.update() 31 32 33if __name__ == "__main__": 34 try: 35 setup() 36 while True: 37 loop() 38 except (Exception, KeyboardInterrupt) as e: 39 try: 40 from utility import print_error_msg 41 42 print_error_msg(e) 43 except ImportError: 44 print("please update to latest firmware")
UiFlow2 应用示例
Constructors
Methods
- Image.setImage(str: file)
设置要显示的图像。
file是要显示的新图像文件的路径。
UiFlow2




