ソースを参照

Change notify argument names to snake_case, add multi_line argument, and convert to appropriate Quasar option names where necessary.

bdenny 2 年 前
コミット
42b5c30102

+ 14 - 5
nicegui/functions/notify.py

@@ -7,10 +7,11 @@ from .. import globals, outbox
 
 def notify(message: Any, *,
            position: Literal['top-left', 'top-right', 'bottom-left', 'bottom-right', 'top', 'bottom', 'left', 'right', 'center'] = 'bottom',
-           closeBtn: Union[bool, str] = False,
+           close_button: Union[bool, str] = False,
            type: Optional[Literal['positive', 'negative', 'warning', 'info', 'ongoing']] = None,
            color: Optional[str] = None,
-           **kwargs,
+           multi_line: Optional[bool] = False,
+           **_kwargs,
            ) -> None:
     """Notification
 
@@ -18,13 +19,21 @@ def notify(message: Any, *,
 
     :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 closeBtn: optional label of a button to dismiss the notification (default: `False`)
+    :param close_button: optional label of a button to dismiss the notification (default: `False`)
     :param type: optional type ("positive", "negative", "warning", "info" or "ongoing")
     :param color: optional color name
+    :param multi_line: optional boolean to enable multi-line notifications
 
     Note: You can pass additional keyword arguments according to `Quasar's Notify API <https://quasar.dev/quasar-plugins/notify#notify-api>`_.
     """
-    options = {key: value for key, value in locals().items() if not key.startswith('_') and value is not None}
+    _arg_map = {'close_button': 'closeBtn',
+                'multi_line':   'multiLine',
+                }
+    options = {_arg_map.get(key, key): value
+               for key, value
+               in locals().items()
+               if not key.startswith('_') and value is not None
+               }
     options['message'] = str(message)
-    options.update(kwargs)
+    options.update(_kwargs)
     outbox.enqueue_message('notify', options, globals.get_client().id)

+ 2 - 2
website/more_documentation/notify_documentation.py

@@ -4,7 +4,7 @@ from ..documentation_tools import text_demo
 
 
 def main_demo() -> None:
-    ui.button('Say hi!', on_click=lambda: ui.notify('Hi!', closeBtn='OK'))
+    ui.button('Say hi!', on_click=lambda: ui.notify('Hi!', close_button='OK'))
 
 
 def more() -> None:
@@ -27,6 +27,6 @@ def more() -> None:
             'Hic quisquam non ad sit assumenda consequuntur esse inventore officia. \n'
             'Corrupti reiciendis impedit vel, '
             'fugit odit quisquam quae porro exercitationem eveniet quasi.',
-            multiLine=True,
+            multi_line=True,
             classes='multi-line-notification',
         ))