Skip to main content

A way to create transparent NetworkTables variables

Project description

NTProp

A simple mechanism for using Network Tables entries as semi-transparent member variables

Installation

Using your Python package manager of choice, just install the ntprop package from PyPI.

pip install ntprop

Usage

To start using these, you just need to import NTPropertyHost from ntprop and have your class inherit from it. From there, any member varaible that is of the types NumberProperty, BooleanProperty, or StringProperty (also from ntprop) will act like a simple, strictly-typed member variable that transparently updates and is updated by the relevant NT entry.

Example

from ntprop import NTPropertyHost, NumberProperty

class Foo(NTPropertyHost):
    # for purposes of type-checking here, we could just call this a float, since there's no difference in 
    # usage at runtime. This is only valid if the owning class is an NTPropertyHost.
    bar: NumberProperty

    def __init__(self):
        self.bar = NumberProperty("ntbar", default=1, readonly=False) #defaults are 0.0 and False, respectively

    def do_something(self):
        # += may work?
        self.bar = self.bar + 1 
        print(self.bar)

It's also possible to use an NTProperty without it being a member of ah NTPropertyHost. To do that, you just need to use the get and set methods of the type. NOTE: These methods are not available in NTPropertyHosts since that type already does the necessary calls to get and set behind the scenes and resolves them prior to returning a value.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntprop-0.1.2.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ntprop-0.1.2-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file ntprop-0.1.2.tar.gz.

File metadata

  • Download URL: ntprop-0.1.2.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.14.4 Darwin/23.4.0

File hashes

Hashes for ntprop-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6f5264e1ef55f296ce16d66e1e54eede0525e0f7cbf6520291cafd785135a1a9
MD5 013780f9202572ab83f860de92e09943
BLAKE2b-256 089b400d7daf7c2e1d6654fdf53d32cc7dad7f662ec924f8a1e25b261ef76a00

See more details on using hashes here.

File details

Details for the file ntprop-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ntprop-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.14.4 Darwin/23.4.0

File hashes

Hashes for ntprop-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d2405c0bf01117e3218dba26b56aff3f534551eb38e284100e65a68214a66e1
MD5 241047524b5bf57a7cd43a7fb621684b
BLAKE2b-256 2dde5d91dc12393aeb07a13014e94e034a4f66afe65c389edf379abc784f2cc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page