Falko Schindler před 3 roky
rodič
revize
36be868b32
2 změnil soubory, kde provedl 11 přidání a 12 odebrání
  1. 2 2
      main.py
  2. 9 10
      nicegui/elements/notify.py

+ 2 - 2
main.py

@@ -296,11 +296,11 @@ with example(ui.menu):
             ui.label('Menu item 2')
             ui.button('Close', on_click=menu.close).props('icon=close text-color=black color=white flat')
 
-    ui.button('Basic menu', on_click=menu.open).props('color=secondary')
+    ui.button('Open menu', on_click=menu.open).props('color=secondary')
 
 with example(ui.notify):
 
-    ui.button('show notification', on_click=lambda: ui.notify(message='Some message', close_button='OK'))
+    ui.button('Show notification', on_click=lambda: ui.notify('Some message', close_button='OK'))
 
 lifecycle = '''### Lifecycle
 

+ 9 - 10
nicegui/elements/notify.py

@@ -6,28 +6,27 @@ import asyncio
 class Notify(Element):
 
     def __init__(self,
-                 message: str = '',
+                 message: str,
+                 *,
                  position: str = 'bottom',
-                 close_button: str = ''
+                 close_button: str = None
                  ):
-        """Notification Element
+        """Notification
 
         Displays a notification on the screen.
 
-        :param message: the content of the notification
-        :param position: possible position: 'top-left', 'top-right', 'bottom-left','bottom-right, 'top', 'bottom', 'left', 'right', 'center'
-        :param close_button: label of the button to dismiss the notification
+        :param message: content of the notification
+        :param position: position on the screen ("top-left", "top-right", "bottom-left","bottom-right, "top", "bottom", "left", "right" or "center", default: "bottom")
+        :param close_button: optional label of a button to dismiss the notification (default: None)
         """
 
-        view = jp.QNotify(message=message, position=position)
-
-        if close_button:
-            view.closeBtn = close_button
+        view = jp.QNotify(message=message, position=position, closeBtn=close_button)
 
         super().__init__(view)
         asyncio.get_event_loop().create_task(self.notify_async())
 
     async def notify_async(self):
+
         self.view.notify = True
         await self.parent_view.update()
         self.view.notify = False