2
2
#
3
3
# SPDX-License-Identifier: MIT
4
4
5
- from ..app import AppBase
6
- from widgets . image import Image
7
- from widgets . label import Label
8
- from M5 import Lcd , Widgets
5
+ from .. import app
6
+ import widgets
7
+ import M5
8
+ from M5 import Widgets
9
9
import os
10
10
import sys
11
11
import time
12
12
import machine
13
13
import boot_option
14
- from ..res import (
15
- APPLIST_UNSELECTED_IMG ,
16
- APPLIST_SELECTED_IMG ,
17
- APPLIST_IMG ,
18
- BAR5_IMG ,
19
- APPLIST_LEFT_IMG ,
20
- APPLIST_RIGHT_IMG ,
21
- )
14
+ from .. import res
22
15
23
16
24
17
class Rectangle :
25
- def __init__ (self , x , y , w , h , color , fill_c , parent = Lcd ) -> None :
18
+ def __init__ (self , x , y , w , h , color , fill_c , parent = M5 . Lcd ) -> None :
26
19
self ._x = x
27
20
self ._y = y
28
21
self ._w = w
@@ -88,12 +81,12 @@ def __len__(self):
88
81
return self .files_len
89
82
90
83
91
- class ListApp (AppBase ):
84
+ class ListApp (app . AppBase ):
92
85
def __init__ (self , icos : dict , data = None ) -> None :
93
86
super ().__init__ ()
94
87
95
88
def on_install (self ):
96
- Lcd .drawImage (APPLIST_UNSELECTED_IMG , 5 + 62 * 3 , 0 )
89
+ M5 . Lcd .drawImage (res . APPLIST_UNSELECTED_IMG , 5 + 62 * 3 , 0 )
97
90
98
91
def on_launch (self ):
99
92
self ._files = FileList ("apps" )
@@ -105,9 +98,9 @@ def on_view(self):
105
98
self ._origin_x = 0
106
99
self ._origin_y = 56
107
100
108
- Lcd .drawImage (APPLIST_SELECTED_IMG , 5 + 62 * 3 , 0 )
109
- Lcd .drawImage (APPLIST_IMG , self ._origin_x + 4 , self ._origin_y + 4 )
110
- Lcd .drawImage (BAR5_IMG , 0 , 220 )
101
+ M5 . Lcd .drawImage (res . APPLIST_SELECTED_IMG , 5 + 62 * 3 , 0 )
102
+ M5 . Lcd .drawImage (res . APPLIST_IMG , self ._origin_x + 4 , self ._origin_y + 4 )
103
+ M5 . Lcd .drawImage (res . BAR5_IMG , 0 , 220 )
111
104
112
105
self ._line_spacing = 36 + 2 + 2
113
106
self ._left_cursor_x = self ._origin_x + 4
@@ -117,25 +110,25 @@ def on_view(self):
117
110
self ._left_cursor_x , self ._left_cursor_y , 10 , 36 , 0xFEFEFE , 0xFEFEFE
118
111
)
119
112
120
- self ._left_img = Image (use_sprite = False )
113
+ self ._left_img = widgets . Image (use_sprite = False )
121
114
self ._left_img .set_pos (self ._left_cursor_x , self ._left_cursor_y )
122
115
self ._left_img .set_size (10 , 36 )
123
- self ._left_img .set_src (APPLIST_LEFT_IMG )
116
+ self ._left_img .set_src (res . APPLIST_LEFT_IMG )
124
117
125
118
self ._right_cursor_x = 320 - 4 - 60 - 10
126
119
self ._right_cursor_y = self ._origin_y + 4 + 2
127
120
128
121
self ._rect1 = Rectangle (
129
- self ._right_cursor_x , self ._right_cursor_y , 10 , 36 , 0xFEFEFE , 0xFEFEFE , parent = Lcd
122
+ self ._right_cursor_x , self ._right_cursor_y , 10 , 36 , 0xFEFEFE , 0xFEFEFE , parent = M5 . Lcd
130
123
)
131
124
132
- self ._right_img = Image (use_sprite = False )
125
+ self ._right_img = widgets . Image (use_sprite = False )
133
126
self ._right_img .set_pos (self ._right_cursor_x , self ._right_cursor_y )
134
127
self ._right_img .set_size (10 , 36 )
135
- self ._right_img .set_src (APPLIST_RIGHT_IMG )
128
+ self ._right_img .set_src (res . APPLIST_RIGHT_IMG )
136
129
137
130
if not hasattr (self , "_label0" ):
138
- self ._label0 = Label (
131
+ self ._label0 = widgets . Label (
139
132
"" ,
140
133
self ._left_cursor_x + 10 ,
141
134
self ._left_cursor_y + 8 ,
@@ -147,7 +140,7 @@ def on_view(self):
147
140
)
148
141
149
142
if not hasattr (self , "_label1" ):
150
- self ._label1 = Label (
143
+ self ._label1 = widgets . Label (
151
144
"" ,
152
145
self ._left_cursor_x + 10 ,
153
146
self ._left_cursor_y + 8 + self ._line_spacing ,
@@ -159,7 +152,7 @@ def on_view(self):
159
152
)
160
153
161
154
if not hasattr (self , "_label2" ):
162
- self ._label2 = Label (
155
+ self ._label2 = widgets . Label (
163
156
"" ,
164
157
self ._left_cursor_x + 10 ,
165
158
self ._left_cursor_y + 8 + self ._line_spacing + self ._line_spacing ,
@@ -171,7 +164,7 @@ def on_view(self):
171
164
)
172
165
173
166
if not hasattr (self , "_label3" ):
174
- self ._label3 = Label (
167
+ self ._label3 = widgets . Label (
175
168
"" ,
176
169
self ._left_cursor_x + 10 ,
177
170
self ._left_cursor_y
@@ -187,10 +180,6 @@ def on_view(self):
187
180
)
188
181
if not hasattr (self , "_labels" ):
189
182
self ._labels = (self ._label0 , self ._label1 , self ._label2 , self ._label3 )
190
- # self._labels.append(self._label0)
191
- # self._labels.append(self._label1)
192
- # self._labels.append(self._label2)
193
- # self._labels.append(self._label3)
194
183
195
184
for label , file in zip (self ._labels , self ._files ):
196
185
file and label and label .set_text (file )
@@ -202,7 +191,7 @@ def on_hide(self):
202
191
pass
203
192
204
193
def on_exit (self ):
205
- Lcd .drawImage (APPLIST_UNSELECTED_IMG , 5 + 62 * 3 , 0 )
194
+ M5 . Lcd .drawImage (res . APPLIST_UNSELECTED_IMG , 5 + 62 * 3 , 0 )
206
195
del (
207
196
self ._left_img ,
208
197
self ._right_img ,
@@ -253,7 +242,7 @@ async def _btnb_event_handler(self, fw):
253
242
file and label and label .set_text (file )
254
243
255
244
async def _btnc_event_handler (self , fw ):
256
- execfile ("apps/" + self ._files [self ._file_pos ]) # noqa: F821
245
+ execfile ("/" . join ([ " apps/", self ._files [self ._file_pos ]]), { "__name__" : "__main__" } ) # noqa: F821
257
246
sys .exit (0 )
258
247
259
248
async def _btnc_hold_event_handler (self , fw ):
0 commit comments