Skip to content

Commit 8e8c00c

Browse files
committed
adding refresh component
Signed-off-by: Valerie Gleason 👌 <[email protected]>
1 parent f05a081 commit 8e8c00c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

examples/sample/sample_panel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import nipanel
66

77
panel = nipanel.StreamlitPanelValueAccessor(panel_id="sample_panel")
8+
panel.refresh()
89

910
st.title("Sample Panel")
1011

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
STREAMLIT_PYTHON_PANEL_SERVICE = "ni.pythonpanel.v1.PythonPanelService"
2+
STREAMLIT_REFRESH_COMPONENT_URL = "http://localhost:42001/panels/refresh"

src/nipanel/_streamlit_panel_value_accessor.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from __future__ import annotations
22

3-
from typing import final
3+
from typing import final, Any
44

55
import grpc
6+
import streamlit.components.v1 as components
67
from ni_measurement_plugin_sdk_service.discovery import DiscoveryClient
78
from ni_measurement_plugin_sdk_service.grpc.channelpool import GrpcChannelPool
89

910
from nipanel._panel_value_accessor import PanelValueAccessor
10-
from nipanel._streamlit_constants import STREAMLIT_PYTHON_PANEL_SERVICE
11+
from nipanel._streamlit_constants import (
12+
STREAMLIT_PYTHON_PANEL_SERVICE,
13+
STREAMLIT_REFRESH_COMPONENT_URL,
14+
)
1115

1216

1317
@final
@@ -43,3 +47,11 @@ def __init__(
4347
grpc_channel_pool=grpc_channel_pool,
4448
grpc_channel=grpc_channel,
4549
)
50+
51+
def refresh(self) -> Any:
52+
"""Get the Streamlit component for refreshing the panel."""
53+
_panel_refresh_component = components.declare_component(
54+
"panelRefreshComponent",
55+
url=f"{STREAMLIT_REFRESH_COMPONENT_URL}/{self.panel_id}",
56+
)
57+
return _panel_refresh_component()

0 commit comments

Comments
 (0)