diff options
author | Walter Bender <walter.bender@gmail.com> | 2011-04-09 11:12:28 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2011-04-09 11:12:28 (GMT) |
commit | f2a694d982fb2ffe07ae7d0d9b9417f38854b4a0 (patch) | |
tree | 1a3f1ccf3661a43a8622a369a104b446dd485272 /plugins/rfid | |
parent | 81a6c0186ef12af97c4ec61e923da9f326d1fd20 (diff) |
add hidden block when device unavailable
Diffstat (limited to 'plugins/rfid')
-rw-r--r-- | plugins/rfid/rfid.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/plugins/rfid/rfid.py b/plugins/rfid/rfid.py index a83bae0..a7fd47c 100644 --- a/plugins/rfid/rfid.py +++ b/plugins/rfid/rfid.py @@ -80,21 +80,29 @@ class Rfid(Plugin): def setup(self): # set up RFID-specific blocks - if self._status: - palette = make_palette('sensor', - colors=["#FF6060", "#A06060"], - help_string=_('Palette of sensor blocks')) + primitive_dictionary['rfid'] = self.prim_read_rfid + palette = make_palette('sensor', + colors=["#FF6060", "#A06060"], + help_string=_('Palette of sensor blocks')) - primitive_dictionary['rfid'] = self.prim_read_camera + if self._status: palette.add_block('rfid', - palette='sensor', style='box-style', label=_('RFID'), help_string=_('read value from RFID device'), value_block=True, prim_name='rfid') - self._parent.lc.def_prim('rfid', 0, - lambda self: primitive_dictionary['rfid'](True)) + else: + palette.add_block('rfid', + hidden=True, + style='box-style', + label=_('RFID'), + help_string=_('read value from RFID device'), + value_block=True, + prim_name='rfid') + + self._parent.lc.def_prim( + 'rfid', 0, lambda self: primitive_dictionary['rfid']()) def _status_report(self): debug_output('Reporting RFID status: %s' % (str(self._status))) @@ -138,3 +146,5 @@ class Rfid(Plugin): def prim_read_rfid(self): if self._status: return self.rfid_idn + else: + return '0' |