Browse Source

code review

Falko Schindler 2 years ago
parent
commit
76bfaac70b
2 changed files with 11 additions and 12 deletions
  1. 6 7
      examples/slideshow/main.py
  2. 5 5
      test_startup.sh

+ 6 - 7
examples/slideshow/main.py

@@ -1,16 +1,15 @@
-import os
+#!/usr/bin/env python3
 from pathlib import Path
 
 from nicegui import ui
-from nicegui.elements.keyboard import KeyEventArguments
+from nicegui.events import KeyEventArguments
 
+folder = Path(__file__).resolve().parent / 'slides'  # image source: https://pixabay.com/
+files = sorted(f.name for f in folder.glob('*.jpg'))
 index = 0
-# NOTE the images are taken from https://pixabay.com/
-folder = Path(__file__).resolve().parent / 'slides'
-files = sorted([f.name for f in folder.glob('**/*.jpg')])
 
 
-def handle_key(event: KeyEventArguments):
+def handle_key(event: KeyEventArguments) -> None:
     global index
     if event.action.keydown:
         if event.key.arrow_right:
@@ -22,7 +21,7 @@ def handle_key(event: KeyEventArguments):
 
 
 ui.add_static_files('/slides', folder)  # serve all files in this folder
-slide = ui.image('slides/' + files[index])  # show the first image
+slide = ui.image(f'slides/{files[index]}')  # show the first image
 ui.keyboard(on_key=handle_key)  # handle keyboard events
 
 ui.run()

+ 5 - 5
test_startup.sh

@@ -27,8 +27,8 @@ check() {
     fi
 }
 
-success=0
-check main.py || success=1
-check examples.py || success=1
-echo exit $success
-test $success -eq 0
+error=0
+check main.py || error=1
+check examples.py || error=1
+check examples/slideshow/main.py || error=1
+test $error -eq 0