Skip to content
Merged
9 changes: 9 additions & 0 deletions examples/sample/sample.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""This example demonstrates how to open/update a Streamlit application using nipanel package."""

import itertools
import math
import pathlib

import nipanel
Expand All @@ -17,6 +19,13 @@
panel.set_value("sample_float", 3.14)
panel.set_value("sample_bool", True)

x_values = [
float(x) for x in itertools.takewhile(lambda p: p < 2 * math.pi, itertools.count(0, 0.05))
]
y_values = [math.sin(x) for x in x_values]
panel.set_value("x_values", x_values)
panel.set_value("y_values", y_values)

input("Press Enter to close the panel...")

panel.close_panel(reset=True)
14 changes: 14 additions & 0 deletions examples/sample/sample_panel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Streamlit application script for displaying values using nipanel package."""

import pandas as pd
import streamlit as st

import nipanel
Expand All @@ -15,9 +16,22 @@
st.write("Integer")
st.write("Float")
st.write("Boolean")
st.write("Line")

with col2:
st.write(panel.get_value("sample_string"))
st.write(panel.get_value("sample_int"))
st.write(panel.get_value("sample_float"))
st.write(panel.get_value("sample_bool"))
st.line_chart(
data=pd.DataFrame(
{
"x": panel.get_value("x_values"),
"y": panel.get_value("y_values"),
}
),
x="x",
y="y",
x_label="x",
y_label="sin(x)",
)
33 changes: 33 additions & 0 deletions protos/ni/pythonpanel/v1/python_panel_types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax = "proto3";

package ni.pythonpanel.v1;

option cc_enable_arenas = true;
option csharp_namespace = "NationalInstruments.PythonPanel.V1";
option go_package = "pythonpanelv1";
option java_multiple_files = true;
option java_outer_classname = "PythonPanelServiceProto";
option java_package = "com.ni.pythonpanel.v1";
option objc_class_prefix = "NIPP";
option php_namespace = "NI\\PythonPanel\\V1";
option ruby_package = "NI::PythonPanel::V1";

message BoolCollection {
repeated bool values = 1;
}

message ByteStringCollection {
repeated bytes values = 1;
}

message FloatCollection {
repeated double values = 1;
}

message IntCollection {
repeated sint64 values = 1;
}

message StringCollection {
repeated string values = 1;
}
34 changes: 34 additions & 0 deletions src/ni/pythonpanel/v1/python_panel_types_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions src/ni/pythonpanel/v1/python_panel_types_pb2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""

import builtins
import collections.abc
import google.protobuf.descriptor
import google.protobuf.internal.containers
import google.protobuf.message
import typing

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing.final
class BoolCollection(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

VALUES_FIELD_NUMBER: builtins.int
@property
def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.bool]: ...
def __init__(
self,
*,
values: collections.abc.Iterable[builtins.bool] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["values", b"values"]) -> None: ...

global___BoolCollection = BoolCollection

@typing.final
class ByteStringCollection(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

VALUES_FIELD_NUMBER: builtins.int
@property
def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.bytes]: ...
def __init__(
self,
*,
values: collections.abc.Iterable[builtins.bytes] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["values", b"values"]) -> None: ...

global___ByteStringCollection = ByteStringCollection

@typing.final
class FloatCollection(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

VALUES_FIELD_NUMBER: builtins.int
@property
def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: ...
def __init__(
self,
*,
values: collections.abc.Iterable[builtins.float] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["values", b"values"]) -> None: ...

global___FloatCollection = FloatCollection

@typing.final
class IntCollection(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

VALUES_FIELD_NUMBER: builtins.int
@property
def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: ...
def __init__(
self,
*,
values: collections.abc.Iterable[builtins.int] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["values", b"values"]) -> None: ...

global___IntCollection = IntCollection

@typing.final
class StringCollection(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

VALUES_FIELD_NUMBER: builtins.int
@property
def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ...
def __init__(
self,
*,
values: collections.abc.Iterable[builtins.str] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["values", b"values"]) -> None: ...

global___StringCollection = StringCollection
4 changes: 4 additions & 0 deletions src/ni/pythonpanel/v1/python_panel_types_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

17 changes: 17 additions & 0 deletions src/ni/pythonpanel/v1/python_panel_types_pb2_grpc.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""

import abc
import collections.abc
import grpc
import grpc.aio
import typing

_T = typing.TypeVar("_T")

class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ...

class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg]
...
Loading
Loading