adding micropython examples (#2286)
* adding micropython examples * adding micropython examples
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
#!/opt/bin/lv_micropython -i
|
||||
import sys
|
||||
import lvgl as lv
|
||||
import display_driver
|
||||
from imagetools import get_png_info, open_png
|
||||
|
||||
# Register PNG image decoder
|
||||
@@ -5,25 +9,24 @@ decoder = lv.img.decoder_create()
|
||||
decoder.info_cb = get_png_info
|
||||
decoder.open_cb = open_png
|
||||
|
||||
# Create a screen with a draggable image
|
||||
|
||||
with open('cogwheel.png','rb') as f:
|
||||
png_data = f.read()
|
||||
|
||||
png_img_dsc = lv.img_dsc_t({
|
||||
'data_size': len(png_data),
|
||||
'data': png_data
|
||||
# Create an image from the png file
|
||||
try:
|
||||
with open('../../assets/img_cogwheel_argb.png','rb') as f:
|
||||
png_data = f.read()
|
||||
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
|
||||
})
|
||||
|
||||
scr = lv.scr_act()
|
||||
img1 = lv.img(lv.scr_act())
|
||||
img1.set_src(img_cogwheel_argb)
|
||||
img1.align(lv.ALIGN.CENTER, 0, -20)
|
||||
img1.set_size(200, 200)
|
||||
|
||||
# Create an image on the left using the decoder
|
||||
|
||||
# lv.img.cache_set_size(2)
|
||||
img1 = lv.img(scr)
|
||||
img1.align(scr, lv.ALIGN.CENTER, 0, -20)
|
||||
img1.set_src(png_img_dsc)
|
||||
|
||||
img2 = lv.img(scr)
|
||||
img2 = lv.img(lv.scr_act())
|
||||
img2.set_src(lv.SYMBOL.OK + "Accept")
|
||||
img2.align(img1, lv.ALIGN.OUT_BOTTOM_MID, 0, 20)
|
||||
img2.align_to(img1, lv.ALIGN.OUT_BOTTOM_MID, 0, 20)
|
||||
|
||||
Reference in New Issue
Block a user