-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit (wip) * wip * add NotificationMessage * update notification example * notification changes * add ability to clear notifications * add notification handle * ruff * changes * nits * add different notif types * clear individual notif func * notif update func * ruff * clean * notification api changes * nits * format * wip setter/getter * better update wip * better update notif api * examples changes for per-client notification api * change to client side api * ruff format * ruff pls * fixes to client api * fixes for post_init and remove notifs * Bump ruff * Remove some unused fields, bump notification limit * Minor refactor, add handle to docs * ruff * minor cleanup 🙂 * Add `color` field * pyright --------- Co-authored-by: Brent Yi <[email protected]>
- Loading branch information
1 parent
0ba85db
commit 2e09df7
Showing
32 changed files
with
399 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
import imageio.v3 as iio | ||
import numpy as onp | ||
|
||
import viser | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import time | ||
|
||
import numpy as onp | ||
|
||
import viser | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import time | ||
|
||
import numpy as onp | ||
|
||
import viser | ||
import viser.transforms as tf | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
import numpy as onp | ||
import trimesh | ||
|
||
import viser | ||
import viser.transforms as tf | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import numpy as np | ||
import numpy as onp | ||
import tyro | ||
|
||
import viser | ||
import viser.transforms as tf | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import time | ||
|
||
import matplotlib | ||
|
||
import viser | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from typing import Optional | ||
|
||
import numpy as onp | ||
|
||
import viser | ||
import viser.transforms as tf | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import numpy as onp | ||
import trimesh | ||
import trimesh.creation | ||
|
||
import viser | ||
|
||
server = viser.ViserServer() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import time | ||
|
||
import numpy as onp | ||
|
||
import viser | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
import imageio.v3 as iio | ||
import numpy as onp | ||
|
||
import viser | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
import numpy as np | ||
import numpy as onp | ||
import tyro | ||
|
||
import viser | ||
import viser.transforms as tf | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
"""Notifications | ||
Examples of adding notifications per client in Viser.""" | ||
|
||
import time | ||
|
||
import viser | ||
|
||
|
||
def main() -> None: | ||
server = viser.ViserServer() | ||
|
||
persistent_notif_button = server.gui.add_button( | ||
"Show persistent notification (default)" | ||
) | ||
timed_notif_button = server.gui.add_button("Show timed notification") | ||
controlled_notif_button = server.gui.add_button("Show controlled notification") | ||
loading_notif_button = server.gui.add_button("Show loading notification") | ||
|
||
remove_controlled_notif = server.gui.add_button("Remove controlled notification") | ||
|
||
@persistent_notif_button.on_click | ||
def _(event: viser.GuiEvent) -> None: | ||
"""Show persistent notification when the button is clicked.""" | ||
client = event.client | ||
assert client is not None | ||
|
||
client.add_notification( | ||
title="Persistent notification", | ||
body="This can be closed manually and does not disappear on its own!", | ||
loading=False, | ||
with_close_button=True, | ||
auto_close=False, | ||
) | ||
|
||
@timed_notif_button.on_click | ||
def _(event: viser.GuiEvent) -> None: | ||
"""Show timed notification when the button is clicked.""" | ||
client = event.client | ||
assert client is not None | ||
|
||
client.add_notification( | ||
title="Timed notification", | ||
body="This disappears automatically after 5 seconds!", | ||
loading=False, | ||
with_close_button=True, | ||
auto_close=5000, | ||
) | ||
|
||
@controlled_notif_button.on_click | ||
def _(event: viser.GuiEvent) -> None: | ||
"""Show controlled notification when the button is clicked.""" | ||
client = event.client | ||
assert client is not None | ||
|
||
controlled_notif = client.add_notification( | ||
title="Controlled notification", | ||
body="This cannot be closed by the user and is controlled in code only!", | ||
loading=False, | ||
with_close_button=False, | ||
auto_close=False, | ||
) | ||
|
||
@remove_controlled_notif.on_click | ||
def _(_) -> None: | ||
"""Remove controlled notification.""" | ||
controlled_notif.remove() | ||
|
||
@loading_notif_button.on_click | ||
def _(event: viser.GuiEvent) -> None: | ||
"""Show loading notification when the button is clicked.""" | ||
client = event.client | ||
assert client is not None | ||
|
||
loading_notif = client.add_notification( | ||
title="Loading notification", | ||
body="This indicates that some action is in progress! It will be updated in 3 seconds.", | ||
loading=True, | ||
with_close_button=False, | ||
auto_close=False, | ||
) | ||
|
||
time.sleep(3.0) | ||
|
||
loading_notif.title = "Updated notification" | ||
loading_notif.body = "This notification has been updated!" | ||
loading_notif.loading = False | ||
loading_notif.with_close_button = True | ||
loading_notif.auto_close = 5000 | ||
loading_notif.color = "green" | ||
|
||
while True: | ||
time.sleep(1.0) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.