Skip to content

Commit b529431

Browse files
ImageView app: simplify imports
1 parent 26bfd89 commit b529431

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import gc
22
import os
33

4-
from mpos import Activity, ui
5-
import mpos.ui.anim
4+
from mpos import Activity, smooth_show, smooth_hide, pct_of_display_width, pct_of_display_height
65

76
class ImageView(Activity):
87

@@ -103,9 +102,9 @@ def onStop(self, screen):
103102

104103
def no_image_mode(self):
105104
self.label.set_text(f"No images found in {self.imagedir}...")
106-
mpos.ui.anim.smooth_hide(self.prev_button)
107-
mpos.ui.anim.smooth_hide(self.delete_button)
108-
mpos.ui.anim.smooth_hide(self.next_button)
105+
smooth_hide(self.prev_button)
106+
smooth_hide(self.delete_button)
107+
smooth_hide(self.next_button)
109108

110109
def show_prev_image(self, event=None):
111110
print("showing previous image...")
@@ -132,21 +131,21 @@ def toggle_fullscreen(self, event=None):
132131

133132
def stop_fullscreen(self):
134133
print("stopping fullscreen")
135-
mpos.ui.anim.smooth_show(self.label)
136-
mpos.ui.anim.smooth_show(self.prev_button)
137-
mpos.ui.anim.smooth_show(self.delete_button)
138-
#mpos.ui.anim.smooth_show(self.play_button)
134+
smooth_show(self.label)
135+
smooth_show(self.prev_button)
136+
smooth_show(self.delete_button)
137+
#smooth_show(self.play_button)
139138
self.play_button.add_flag(lv.obj.FLAG.HIDDEN) # make it not accepting focus
140-
mpos.ui.anim.smooth_show(self.next_button)
139+
smooth_show(self.next_button)
141140

142141
def start_fullscreen(self):
143142
print("starting fullscreen")
144-
mpos.ui.anim.smooth_hide(self.label)
145-
mpos.ui.anim.smooth_hide(self.prev_button, hide=False)
146-
mpos.ui.anim.smooth_hide(self.delete_button, hide=False)
147-
#mpos.ui.anim.smooth_hide(self.play_button, hide=False)
143+
smooth_hide(self.label)
144+
smooth_hide(self.prev_button, hide=False)
145+
smooth_hide(self.delete_button, hide=False)
146+
#smooth_hide(self.play_button, hide=False)
148147
self.play_button.remove_flag(lv.obj.FLAG.HIDDEN) # make it accepting focus
149-
mpos.ui.anim.smooth_hide(self.next_button, hide=False)
148+
smooth_hide(self.next_button, hide=False)
150149
self.unfocus() # focus on the invisible center button, not previous or next
151150

152151
def show_prev_image_if_fullscreen(self, event=None):
@@ -272,8 +271,8 @@ def scale_image(self):
272271
pct = 100
273272
else:
274273
pct = 70
275-
lvgl_w = mpos.ui.pct_of_display_width(pct)
276-
lvgl_h = mpos.ui.pct_of_display_height(pct)
274+
lvgl_w = pct_of_display_width(pct)
275+
lvgl_h = pct_of_display_height(pct)
277276
print(f"scaling to size: {lvgl_w}x{lvgl_h}")
278277
header = lv.image_header_t()
279278
self.image.decoder_get_info(self.image.get_src(), header)

internal_filesystem/lib/mpos/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from .ui.focus import save_and_clear_current_focusgroup
4040
from .ui.gesture_navigation import handle_back_swipe, handle_top_swipe
4141
from .ui.util import shutdown, set_foreground_app, get_foreground_app
42+
from .ui.anim import smooth_show, smooth_hide
4243
from .ui import focus_direction
4344

4445
# Utility modules
@@ -78,12 +79,13 @@
7879
"save_and_clear_current_focusgroup",
7980
"handle_back_swipe", "handle_top_swipe",
8081
"shutdown", "set_foreground_app", "get_foreground_app",
82+
"smooth_show", "smooth_hide",
8183
"focus_direction",
8284
# Testing utilities
8385
"wait_for_render", "capture_screenshot", "simulate_click", "get_widget_coords",
8486
"find_label_with_text", "verify_text_present", "print_screen_labels", "find_text_on_screen",
8587
"click_button", "click_label", "click_keyboard_button", "find_button_with_text",
86-
"get_all_widgets_with_text"
88+
"get_all_widgets_with_text",
8789
# Submodules
8890
"apps", "ui", "config", "net", "content", "time", "sensor_manager",
8991
"sdcard", "battery_voltage", "audio", "hardware", "bootloader"

internal_filesystem/lib/mpos/ui/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .util import shutdown, set_foreground_app, get_foreground_app
1717
from .setting_activity import SettingActivity
1818
from .settings_activity import SettingsActivity
19+
from .anim import smooth_show, smooth_hide
1920
from . import focus_direction
2021

2122
# main_display is assigned by board-specific initialization code
@@ -35,5 +36,6 @@
3536
"shutdown", "set_foreground_app", "get_foreground_app",
3637
"SettingActivity",
3738
"SettingsActivity",
39+
"smooth_show", "smooth_hide",
3840
"focus_direction"
3941
]

0 commit comments

Comments
 (0)