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.2.0.tar.gz (2.6 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.2.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ntprop-0.2.0.tar.gz
  • Upload date:
  • Size: 2.6 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.2.0.tar.gz
Algorithm Hash digest
SHA256 5507f160f77b4b64303013bc0b6ed678940887d845198034bccdc49127605ab3
MD5 bade4f510253045741e85d4a0a8d67f6
BLAKE2b-256 70e017cc3db167a0323dbd75cfc444e62dff728d9fcd165c7667020901122df5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ntprop-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe737b4206d8d05badd574df34743f112fa1af23344a43e313d175f27962171e
MD5 5c31717c340c36a95dd4d3be0aaf7bd1
BLAKE2b-256 7b1cd2fb90bbd7bad5d671103962ae6f3342fea26f08c9f01fefbbd4d3a0a811

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