1+ """NI Panel."""
2+
13import uuid
2- import grpc
3- from google .protobuf import any_pb2
4- import ni .pythonpanel .v1 .python_panel_service_pb2 as python_panel_service_pb2
5- import ni .pythonpanel .v1 .python_panel_service_pb2_grpc as python_panel_service_pb2_grpc
4+ from types import TracebackType
5+ from typing import Optional , Type
66
77
88class NiPanel :
9- """
10- This class allows you to access controls on the panel
11- """
9+ """This class allows you to access controls on the panel."""
1210
13- def __init__ (self ):
11+ def __init__ (self ) -> None :
12+ """Initialize the NiPanel instance."""
1413 self ._stub = None # will be a PythonPanelServiceStub
15- self .panel_uri = None
16- self .panel_id = None
14+ self .panel_uri = ""
15+ self .panel_id = ""
1716
18- def __enter__ (self ):
17+ def __enter__ (self ) -> "NiPanel" :
18+ """Enter the runtime context related to this object."""
1919 self .connect ()
2020 return self
2121
22- def __exit__ (self , exc_type , exc_value , exc_traceback ):
22+ def __exit__ (
23+ self ,
24+ exctype : Optional [Type [BaseException ]],
25+ excinst : Optional [BaseException ],
26+ exctb : Optional [TracebackType ],
27+ ) -> Optional [bool ]:
28+ """Exit the runtime context related to this object."""
2329 self .disconnect ()
30+ return None
2431
2532 @classmethod
26- def streamlit_panel (cls , streamlit_script_path : str ):
27- """
28- Create a panel using a streamlit script for the user interface
33+ def streamlit_panel (cls , streamlit_script_path : str ) -> "NiPanel" :
34+ """Create a panel using a streamlit script for the user interface.
2935
3036 Args:
3137 streamlit_script_path: The file path of the streamlit script
@@ -38,36 +44,30 @@ def streamlit_panel(cls, streamlit_script_path: str):
3844 panel .panel_id = str (uuid .uuid4 ())
3945 return panel
4046
41- def connect (self ):
42- """
43- Connect to the panel and open it.
44- """
45- # TODO: AB#3095680 - Use gRPC pool management from the Measurement Plugin SDK, create the _stub, and call _stub.Connect
47+ def connect (self ) -> None :
48+ """Connect to the panel and open it."""
49+ # TODO: AB#3095680 - Use gRPC pool management, create the _stub, and call _stub.Connect
4650 pass
4751
48- def disconnect (self ):
49- """
50- Disconnect from the panel (does not close the panel).
51- """
52- # TODO: AB#3095680 - Use gRPC pool management from the Measurement Plugin SDK, call _stub.Disconnect
52+ def disconnect (self ) -> None :
53+ """Disconnect from the panel (does not close the panel)."""
54+ # TODO: AB#3095680 - Use gRPC pool management, call _stub.Disconnect
5355 pass
5456
55- def get_value (self , value_id : str ):
56- """
57- Get the value for a control on the panel
57+ def get_value (self , value_id : str ) -> object :
58+ """Get the value for a control on the panel.
5859
5960 Args:
6061 value_id: The id of the value
6162
6263 Returns:
6364 object: The value
6465 """
65- # TODO: AB#3095681 - get the Any from _stub.GetValue and convert it to the correct type to return it
66+ # TODO: AB#3095681 - get the Any from _stub.GetValue and convert it to the correct type
6667 return "placeholder value"
6768
68- def set_value (self , value_id : str , value ):
69- """
70- Set the value for a control on the panel
69+ def set_value (self , value_id : str , value : object ) -> None :
70+ """Set the value for a control on the panel.
7171
7272 Args:
7373 value_id: The id of the value
0 commit comments