You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
imageview: update
This commit is contained in:
@@ -677,3 +677,27 @@ img = lv.image(lv.screen_active())
|
||||
#img.set_src("P:/data/images/icon_64x64.jpg")
|
||||
img.set_src("P:../artwork/icon_64x64.jpg")
|
||||
|
||||
|
||||
|
||||
group = sdlkeyboard.get_group()
|
||||
#group.remove_all_objs()
|
||||
group = lv.group_create()
|
||||
#group.set_default()
|
||||
|
||||
group = lv.group_get_default()
|
||||
group.get_focused()
|
||||
|
||||
group.remove_all_objs()
|
||||
|
||||
screen = lv.obj()
|
||||
lv.screen_load(screen)
|
||||
|
||||
ta1 = lv.textarea(screen)
|
||||
ta1.align(lv.ALIGN.TOP_MID,0,0)
|
||||
#group.add_obj(ta1)
|
||||
|
||||
b = lv.button(screen)
|
||||
b.center()
|
||||
|
||||
import task_handler
|
||||
task_handler.TaskHandler(duration=5) # 5ms is recommended for MicroPython+LVGL on desktop
|
||||
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import time
|
||||
|
||||
from mpos.apps import Activity
|
||||
import mpos.ui
|
||||
|
||||
class ImageView(Activity):
|
||||
|
||||
@@ -19,20 +20,27 @@ class ImageView(Activity):
|
||||
screen = lv.obj()
|
||||
self.image = lv.image(screen)
|
||||
self.image.set_size(128, 128)
|
||||
self.image.align(lv.ALIGN.BOTTOM_MID,0,0)
|
||||
self.image.center()
|
||||
self.label = lv.label(screen)
|
||||
self.label.set_text('Hello Images!')
|
||||
self.label.align(lv.ALIGN.TOP_MID,0,0)
|
||||
self.next_button = lv.button(screen)
|
||||
self.next_button.align(lv.ALIGN.BOTTOM_RIGHT,0,0)
|
||||
self.next_button.add_event_cb(lambda e: self.show_next_image(),lv.EVENT.CLICKED,None)
|
||||
next_label = lv.label(self.next_button)
|
||||
next_label.set_text(">")
|
||||
self.prev_button = lv.button(screen)
|
||||
self.prev_button.align(lv.ALIGN.BOTTOM_LEFT,0,0)
|
||||
self.prev_button.add_event_cb(lambda e: self.show_prev_image(),lv.EVENT.CLICKED,None)
|
||||
prev_label = lv.label(self.prev_button)
|
||||
prev_label.set_text("<")
|
||||
prev_label.set_text(lv.SYMBOL.LEFT)
|
||||
self.play_button = lv.button(screen)
|
||||
self.play_button.align(lv.ALIGN.BOTTOM_MID,0,0)
|
||||
self.play_button.add_event_cb(lambda e: self.play(),lv.EVENT.CLICKED,None)
|
||||
play_label = lv.label(self.play_button)
|
||||
play_label.set_text(lv.SYMBOL.PLAY)
|
||||
self.next_button = lv.button(screen)
|
||||
self.next_button.align(lv.ALIGN.BOTTOM_RIGHT,0,0)
|
||||
self.next_button.add_event_cb(lambda e: self.show_next_image(),lv.EVENT.CLICKED,None)
|
||||
#self.next_button.add_event_cb(self.touch_cb, lv.EVENT.ALL, None)
|
||||
next_label = lv.label(self.next_button)
|
||||
next_label.set_text(lv.SYMBOL.RIGHT)
|
||||
#screen.add_event_cb(self.touch_cb, lv.EVENT.ALL, None)
|
||||
self.setContentView(screen)
|
||||
|
||||
def onResume(self, screen):
|
||||
@@ -55,6 +63,27 @@ class ImageView(Activity):
|
||||
if self.image_timer:
|
||||
print("ImageView: deleting image_timer")
|
||||
self.image_timer.delete()
|
||||
|
||||
def touch_cb(self, event):
|
||||
global canvas
|
||||
event_code=event.get_code()
|
||||
#print(f"got event {event_code}")
|
||||
# Ignore:
|
||||
# =======
|
||||
# 19: HIT_TEST
|
||||
# COVER_CHECK
|
||||
# DRAW_MAIN
|
||||
# DRAW_MAIN_BEGIN
|
||||
# DRAW_MAIN_END
|
||||
# DRAW_POST
|
||||
# DRAW_POST_BEGIN
|
||||
# DRAW_POST_END
|
||||
# 39: CHILD_CHANGED
|
||||
# GET_SELF_SIZE
|
||||
if event_code not in [19,23,25,26,27,28,29,30,39,49]:
|
||||
name = mpos.ui.get_event_name(event_code)
|
||||
print(f"lv_event_t: code={event_code}, name={name}") # target={event.get_target()}, user_data={event.get_user_data()}, param={event.get_param()}
|
||||
|
||||
|
||||
def show_prev_image(self, event=None):
|
||||
print("showing previous image...")
|
||||
@@ -68,6 +97,9 @@ class ImageView(Activity):
|
||||
print(f"show_prev_image showing {name}")
|
||||
self.show_image(name)
|
||||
|
||||
def play(self, event=None):
|
||||
print("playing...")
|
||||
|
||||
def show_next_image(self, event=None):
|
||||
print("showing next image...")
|
||||
if len(self.images) < 1:
|
||||
|
||||
@@ -40,7 +40,6 @@ def catch_escape_key(indev, indev_data):
|
||||
mpos.ui.back_screen()
|
||||
sdlkeyboard._read(indev, indev_data)
|
||||
|
||||
|
||||
import sdl_keyboard
|
||||
sdlkeyboard = sdl_keyboard.SDLKeyboard()
|
||||
sdlkeyboard._indev_drv.set_read_cb(catch_escape_key) # check for escape
|
||||
@@ -50,9 +49,6 @@ sdlkeyboard.set_paste_text_callback(mpos.clipboard.paste_text)
|
||||
# global canvas
|
||||
# event_code=event.get_code()
|
||||
# print(f"boot_unix: code={event_code}") # target={event.get_target()}, user_data={event.get_user_data()}, param={event.get_param()}
|
||||
|
||||
#keyboard.add_event_cb(keyboard_cb, lv.EVENT.ALL, None)
|
||||
|
||||
|
||||
print("boot_unix.py finished")
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ except Exception as e:
|
||||
print("main.py: WARNING: could not import/run freezefs_mount_builtin: ", e)
|
||||
|
||||
from mpos import apps
|
||||
|
||||
apps.execute_script("builtin/system/button.py", True) # Install button handler through IRQ
|
||||
|
||||
apps.auto_connect()
|
||||
|
||||
Reference in New Issue
Block a user