-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
471 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
from pyrediseasyio import SingleIO | ||
from pyrediseasyio.io.single_io import SingleIO | ||
|
||
|
||
class NumericIO(SingleIO): | ||
pass | ||
def __init__(self, name: str, addr: str = None, default: float = 0.0, **kwargs): | ||
""" | ||
:param name: A human readable name to give to the IO | ||
:param addr: An optional address (key), if not given, them namespace + member name will be used | ||
:param default: The value to assign to the IO if no key is found during read | ||
:param kwargs: | ||
- units: str: Optional units to assign to the IO | ||
- on_value: str: The 'display_value' property will optionally return this value when the value is True | ||
- on_value: str: The 'display_value' property will optionally return this value when the value is False | ||
- namespace: str: Optional leading text to apply to the address to makes its key unique | ||
- min: The smallest allowable number for the entry, reads and writes will be limited by this. | ||
- max: The largest allowable number for the entry, reads and writes will be limited by this. | ||
""" | ||
super().__init__(name, addr, default, **kwargs) | ||
|
||
self.min = kwargs.get('min') | ||
self.max = kwargs.get('max') | ||
|
||
|
||
def read(self): | ||
val = super().read() | ||
if val is None: | ||
return val | ||
if self.max is not None and val > self.max: | ||
val = self.max | ||
if self.min is not None and val < self.min: | ||
val = self.min | ||
return val | ||
|
||
def write(self, value): | ||
if value is None: | ||
return super().write(self, value) | ||
value = self._convert_type(value) | ||
if self.max is not None and value > self._convert_type(self.max): | ||
value = self.max | ||
if self.min is not None and value < self._convert_type(self.min): | ||
value = self.min | ||
super().write(value) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from dominate import document | ||
from dominate.tags import div, button | ||
from collections import namedtuple | ||
import gettext | ||
|
||
_ = gettext.gettext | ||
|
||
Btn = namedtuple("Btn", "cls val action") | ||
|
||
keys = [ | ||
Btn('number-button', _("1"), 1), | ||
Btn('number-button', _("2"), 2), | ||
Btn('number-button', _("3"), 3), | ||
Btn('action-button', _("Del"), 'Del'), | ||
Btn('number-button', _("4"), 4), | ||
Btn('number-button', _("5"), 5), | ||
Btn('number-button', _("6"), 6), | ||
Btn('action-button', _("Clear"), 'Clear'), | ||
Btn('number-button', _("7"), 7), | ||
Btn('number-button', _("8"), 8), | ||
Btn('number-button', _("9"), 9), | ||
Btn('action-button', _("Cancel"), 'Cancel'), | ||
Btn('number-button plus-minus-button', _("+/-"), 'Sign'), | ||
Btn('number-button', _("0"), 0), | ||
Btn('number-button decimal_button', _("."), 'Dec'), | ||
Btn('action-button ok-button', _("Ok"), 'Ok') | ||
] | ||
|
||
def keyboard(doc: document): | ||
with doc.body: | ||
with div(cls="easyio_number_keyboard"): | ||
with div(cls='grid-container'): | ||
div("Title", cls = "title") | ||
div(0, cls='entry', id="easy_io_number_keyboard_entry") | ||
div('', cls='original') | ||
|
||
for key in keys: | ||
button(key.val, cls=key.cls, onclick=f"EasyIoNumericEntryKeyPressed('{key.action}')") | ||
|
||
div('', cls='max') | ||
div('', cls='min') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.