8000 Small fixes to examples (#171) · wired8/lv_binding_micropython@6e613c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e613c0

Browse files
authored
Small fixes to examples (lvgl#171)
Minor fixes, for compliance with the JS port: - Import usys instead of sys - Don't rely on __file__, which may be missing on the JS port * Update Dynamic_loading_font_example.py * Update advanced_demo.py * Update custom_widget_example.py * Update example1.py * Update example2.py * Update png_example.py * Update uasyncio_example1.py * Update png_example.py * Update Dynamic_loading_font_example.py
1 parent 2a87399 commit 6e613c0

File tree

8 files changed

+16
-11
lines changed

8 files changed

+16
-11
lines changed

examples/Dynamic_loading_font_example.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
# MICROPYPATH=./:../lib ../../../ports/unix/micropython -i Dynamic_loading_font_example.py
44
#
55

6-
import sys
6+
import usys as sys
77
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419
88

9-
script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.'
9+
try:
10+
script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.'
11+
except NameError:
12+
script_path = ''
1013

1114
import lvgl as lv
1215
import fs_driver

examples/advanced_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys
1+
import usys as sys
22
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419
33

44
# See: https://pymotw.com/2/sys/tracing.html

examples/custom_widget_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Initializations
66
##############################################################################
77

8-
import sys
8+
import usys as sys
99
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419
1010

1111
import lvgl as lv

examples/example1.py

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# init
22

3-
import sys
3+
import usys as sys
44
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419
55

66
import lvgl as lv

examples/example2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# init
33

4-
import sys
4+
import usys as sys
55
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419
66

77
import ustruct as struct

examples/example3.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import sys
1+
import usys as sys
22
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419
33

4-
import time
54
import lv_utils
65
import lvgl as lv
76

examples/png_example.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
##############################################################################
77

8-
import sys
8+
import usys as sys
99
sys.path.append('') # See: https://github.com/micropython/micropython/issues/6419
1010

1111
import lvgl as lv
@@ -18,7 +18,10 @@
1818
driver = display_driver_utils.driver()
1919
scr = lv.scr_act()
2020
lv.img.cache_set_size(2)
21-
script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.'
21+
try:
22+
script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.'
23+
except NameError:
24+
script_path = ''
2225

2326
# Register an image decoder
2427

examples/uasyncio_example1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Workaround for including frozen modules when running micropython with a script argument
1717
# https://github.com/micropython/micropython/issues/6419
18-
import sys
18+
import usys as sys
1919
sys.path.append('')
2020

2121
# Imports

0 commit comments

Comments
 (0)
0