Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ginazhouhuiwu committed Jun 18, 2024
1 parent 2b5687c commit 06f440e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
5 changes: 2 additions & 3 deletions examples/24_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ def _(_) -> None:
notif = server.gui.add_notification(
title="Notification",
body="You have clicked a button!",
withCloseButton=True,
with_close_button=True,
loading=False,
autoClose=2000,
auto_close=2000,
)
notif.show()

@clear_button.on_click
def _(_) -> None:
Expand Down
8 changes: 4 additions & 4 deletions src/viser/_gui_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,9 +874,9 @@ def add_notification(
self,
title: str,
body: str,
withCloseButton: bool,
with_close_button: bool,
loading: bool,
autoClose: int | bool = False,
auto_close: int | Literal[False],
) -> GuiNotificationHandle:
"""Add a notification, which can be toggled on/off in the GUI.
Expand All @@ -895,9 +895,9 @@ def add_notification(
notification=_messages.NotificationMessage(
title=title,
body=body,
withCloseButton=withCloseButton,
withCloseButton=with_close_button,
loading=loading,
autoClose=autoClose,
autoClose=auto_close,
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/viser/_gui_handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class GuiNotificationHandle:
gui_api: GuiApi
notification: NotificationMessage

def show(self):
def __post_init__(self) -> None:
self.gui_api._websock_interface.queue_message(self.notification)


Expand Down
4 changes: 2 additions & 2 deletions src/viser/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class NotificationMessage(Message):

title: str
body: str
withCloseButton: bool
with_close_button: bool
loading: bool
autoClose: Union[int, bool]
auto_close: Union[int, Literal[False]]


@dataclasses.dataclass
Expand Down
4 changes: 2 additions & 2 deletions src/viser/client/src/WebsocketInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ function useMessageHandler() {
// id: notificationId,
title: message.title,
message: message.body,
withCloseButton: message.withCloseButton,
withCloseButton: message.with_close_button,
loading: message.loading,
autoClose: message.autoClose,
autoClose: message.auto_close,
});
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/viser/client/src/WebsocketMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export interface NotificationMessage {
type: "NotificationMessage";
title: string;
body: string;
withCloseButton: boolean;
with_close_button: boolean;
loading: boolean;
autoClose: number | boolean;
auto_close: number | false;
}
/** Clear notification message.
*
Expand Down

0 comments on commit 06f440e

Please sign in to comment.