Falko Schindler 2 år sedan
förälder
incheckning
18df3b9661
2 ändrade filer med 6 tillägg och 9 borttagningar
  1. 5 8
      examples/search-as-you-type/main.py
  2. 1 1
      nicegui/templates/index.html

+ 5 - 8
examples/search-as-you-type/main.py

@@ -1,5 +1,4 @@
 #!/usr/bin/env python3
-
 import asyncio
 from typing import Optional
 
@@ -13,7 +12,6 @@ running_query: Optional[asyncio.Task] = None
 
 async def search(e: events.ValueChangeEventArguments) -> None:
     '''Search for cocktails as you type.'''
-
     global running_query
     if running_query:
         running_query.cancel()  # cancel the previous query; happens when you type fast
@@ -25,16 +23,15 @@ async def search(e: events.ValueChangeEventArguments) -> None:
     if response.text == '':
         return
     with results:  # enter the context of the the results row
-        for o in response.json()['drinks'] or []:  # iterate over the response data of the api
-            with ui.image(o['strDrinkThumb']).classes('w-64'):
-                ui.label(o['strDrink']).classes('absolute-bottom text-subtitle2 text-center')
+        for drink in response.json()['drinks'] or []:  # iterate over the response data of the api
+            with ui.image(drink['strDrinkThumb']).classes('w-64'):
+                ui.label(drink['strDrink']).classes('absolute-bottom text-subtitle2 text-center')
     running_query = None
 
 # create a search field which is initially focused and leaves space at the top
-search_field = ui.input(on_change=search)\
-    .props('autofocus outlined rounded item-aligned input-class="ml-3"')\
+search_field = ui.input(on_change=search) \
+    .props('autofocus outlined rounded item-aligned input-class="ml-3"') \
     .classes('w-96 self-center mt-24 transition-all')
 results = ui.row()
 
-
 ui.run()

+ 1 - 1
nicegui/templates/index.html

@@ -145,7 +145,7 @@
       {{ js_imports | safe }}
 
       const dark = {{ dark }};
-      Quasar.Dark.set(dark === None ? "auto": dark);
+      Quasar.Dark.set(dark === None ? "auto" : dark);
 
       app.mount("#app");
     </script>