Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/taconstants.py40
-rw-r--r--TurtleArt/taprimitive.py28
-rw-r--r--plugins/audio_sensors_plugin.py12
-rw-r--r--plugins/camera_plugin.py7
-rw-r--r--plugins/rfid_plugin.py3
5 files changed, 59 insertions, 31 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index 61b64a0..886bfa3 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -248,6 +248,46 @@ PORTFOLIO_STYLE_1x1 = ['template1x1', 'template1x1a']
PORTFOLIO_STYLE_2x1 = ['template2x1']
PORTFOLIO_STYLE_1x2 = ['template1x2']
+BLOCK_STYLES = {'basic-style-head': BASIC_STYLE_HEAD,
+ 'basic-style-head-1arg': BASIC_STYLE_HEAD_1ARG,
+ 'basic-style-tail': BASIC_STYLE_TAIL,
+ 'basic-style': BASIC_STYLE,
+ 'basic-style-extended-vertical': BASIC_STYLE_EXTENDED_VERTICAL,
+ 'invisible': INVISIBLE,
+ 'basic-style-extended': BASIC_STYLE_EXTENDED,
+ 'basic-style-1arg': BASIC_STYLE_1ARG,
+ 'basic-style-var-arg': BASIC_STYLE_VAR_ARG,
+ 'bullet-style': BULLET_STYLE,
+ 'basic-style-2arg': BASIC_STYLE_2ARG,
+ 'box-style': BOX_STYLE,
+ 'box-style-media': BOX_STYLE_MEDIA,
+ 'number-style': NUMBER_STYLE,
+ 'number-style-var-arg': NUMBER_STYLE_VAR_ARG,
+ 'number-style-block': NUMBER_STYLE_BLOCK,
+ 'number-style-porch': NUMBER_STYLE_PORCH,
+ 'number-style-1arg': NUMBER_STYLE_1ARG,
+ 'number-style-1strarg': NUMBER_STYLE_1STRARG,
+ 'compare-style': COMPARE_STYLE,
+ 'compare-porch-style': COMPARE_PORCH_STYLE,
+ 'boolean-style': BOOLEAN_STYLE,
+ 'not-style': NOT_STYLE,
+ 'flow-style': FLOW_STYLE,
+ 'flow-style-tail': FLOW_STYLE_TAIL,
+ 'flow-style-1arg': FLOW_STYLE_1ARG,
+ 'flow-style-boolean': FLOW_STYLE_BOOLEAN,
+ 'flow-style-while': FLOW_STYLE_WHILE,
+ 'flow-style-else': FLOW_STYLE_ELSE,
+ 'collapsible-top': COLLAPSIBLE_TOP,
+ 'collapsible-top-no-arm': COLLAPSIBLE_TOP_NO_ARM,
+ 'collapsible-top-no-label': COLLAPSIBLE_TOP_NO_LABEL,
+ 'collapsible-top-no-arm-no-label':
+ COLLAPSIBLE_TOP_NO_ARM_NO_LABEL,
+ 'collapsible-bottom': COLLAPSIBLE_BOTTOM,
+ 'portfolio-style-2x2': PORTFOLIO_STYLE_2x2,
+ 'portfolio-style-1x1': PORTFOLIO_STYLE_1x1,
+ 'portfolio-style-2x1': PORTFOLIO_STYLE_2x1,
+ 'portfolio-style-1x2': PORTFOLIO_STYLE_1x2}
+
#
# Blocks that are expandable
#
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 47180b8..4abc54f 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -19,22 +19,8 @@
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
-from taconstants import EXPANDABLE, EXPANDABLE_BLOCKS, EXPANDABLE_ARGS, \
- PRIMITIVES, OLD_NAMES, BLOCK_SCALE, BLOCK_NAMES, CONTENT_BLOCKS, \
- PALETTES, COLORS, BASIC_STYLE_HEAD, BASIC_STYLE_HEAD_1ARG, \
- BASIC_STYLE_TAIL, BASIC_STYLE, BASIC_STYLE_EXTENDED, BASIC_STYLE_1ARG, \
- BASIC_STYLE_VAR_ARG, BULLET_STYLE, BASIC_STYLE_2ARG, BOX_STYLE, \
- BOX_STYLE_MEDIA, NUMBER_STYLE, NUMBER_STYLE_VAR_ARG, NUMBER_STYLE_BLOCK, \
- NUMBER_STYLE_PORCH, NUMBER_STYLE_1ARG, NUMBER_STYLE_1STRARG, \
- COMPARE_STYLE, BOOLEAN_STYLE, NOT_STYLE, FLOW_STYLE, FLOW_STYLE_TAIL, \
- FLOW_STYLE_1ARG, FLOW_STYLE_BOOLEAN, FLOW_STYLE_WHILE, FLOW_STYLE_ELSE, \
- COLLAPSIBLE_TOP, COLLAPSIBLE_TOP_NO_ARM, COLLAPSIBLE_TOP_NO_LABEL, \
- COLLAPSIBLE_TOP_NO_ARM_NO_LABEL, COLLAPSIBLE_BOTTOM, PORTFOLIO_STYLE_2x2, \
- PORTFOLIO_STYLE_1x1, PORTFOLIO_STYLE_2x1, PORTFOLIO_STYLE_1x2, \
- STANDARD_STROKE_WIDTH, BOX_COLORS, GRADIENT_COLOR, COMPARE_PORCH_STYLE, \
- BASIC_STYLE_EXTENDED_VERTICAL, CONSTANTS, INVISIBLE, PALETTE_NAMES, \
- HELP_STRINGS, DEFAULTS, SPECIAL_NAMES
-
+from taconstants import BLOCK_STYLES, BLOCK_NAMES, HELP_STRINGS, PALETTES, \
+ PALETTE_NAMES, CONTENT_BLOCKS, PRIMITIVES, DEFAULTS, SPECIAL_NAMES
from talogo import VALUE_BLOCKS
from tautils import debug_output
@@ -63,7 +49,7 @@ class Primitive():
debug_output('You must specify a style for your block')
return
else:
- self._style.append(self._name)
+ BLOCK_STYLES[self._style].append(self._name)
if self._label is not None:
BLOCK_NAMES[self._name] = self._label
@@ -73,6 +59,8 @@ class Primitive():
if self._help is not None:
HELP_STRINGS[self._name] = self._help
+ else:
+ HELP_STRINGS[self._name] = ''
if self._value_block:
VALUE_BLOCKS.append(self._name)
@@ -120,8 +108,10 @@ class Primitive():
self._default = [default]
def set_style(self, style):
- self._style = style
+ if style not in BLOCK_STYLES:
+ debug_output('Unknown style: %s' % (style))
+ else:
+ self._style = style
def set_prim_name(self, prim_name):
self._prim_name = prim_name
-
diff --git a/plugins/audio_sensors_plugin.py b/plugins/audio_sensors_plugin.py
index 8f0e2d4..4c9a364 100644
--- a/plugins/audio_sensors_plugin.py
+++ b/plugins/audio_sensors_plugin.py
@@ -38,7 +38,7 @@ from audio.audiograb import AudioGrab_Unknown, AudioGrab_XO1, AudioGrab_XO15, \
from audio.ringbuffer import RingBuffer1d
from TurtleArt.taprimitive import Primitive
-from TurtleArt.taconstants import BOX_STYLE, XO1, XO15
+from TurtleArt.taconstants import XO1, XO15
from TurtleArt.talogo import PLUGIN_DICTIONARY
from TurtleArt.tautils import get_path
@@ -86,7 +86,7 @@ class Audio_sensors_plugin(Plugin):
sound = Primitive('sound')
sound.set_palette('sensor')
- sound.set_style(BOX_STYLE)
+ sound.set_style('box-style')
sound.set_label(_('sound'))
sound.set_help(_('raw microphone input signal'))
sound.set_value_block(True)
@@ -98,7 +98,7 @@ class Audio_sensors_plugin(Plugin):
volume = Primitive('volume')
volume.set_palette('sensor')
- volume.set_style(BOX_STYLE)
+ volume.set_style('box-style')
volume.set_label(_('volume'))
volume.set_help(_('microphone input volume'))
volume.set_value_block(True)
@@ -111,7 +111,7 @@ class Audio_sensors_plugin(Plugin):
pitch = Primitive('pitch')
if PITCH_AVAILABLE:
pitch.set_palette('sensor')
- pitch.set_style(BOX_STYLE)
+ pitch.set_style('box-style')
pitch.set_label(_('pitch'))
pitch.set_help(_('microphone input pitch'))
pitch.set_value_block(True)
@@ -124,7 +124,7 @@ class Audio_sensors_plugin(Plugin):
if self.hw in [XO1, XO15]:
resistance = Primitive('resistance')
resistance.set_palette('sensor')
- resistance.set_style(BOX_STYLE)
+ resistance.set_style('box-style')
resistance.set_label(_('resistance'))
resistance.set_help(_('sensor input resistance'))
resistance.set_value_block(True)
@@ -136,7 +136,7 @@ class Audio_sensors_plugin(Plugin):
voltage = Primitive('voltage')
voltage.set_palette('sensor')
- voltage.set_style(BOX_STYLE)
+ voltage.set_style('box-style')
voltage.set_label(_('voltage'))
voltage.set_help(_('sensor input voltage'))
voltage.set_value_block(True)
diff --git a/plugins/camera_plugin.py b/plugins/camera_plugin.py
index 960dc54..c4e6bc8 100644
--- a/plugins/camera_plugin.py
+++ b/plugins/camera_plugin.py
@@ -32,7 +32,6 @@ from camera.v4l2 import v4l2_control, V4L2_CID_AUTOGAIN, VIDIOC_G_CTRL, \
from plugin import Plugin
from TurtleArt.taprimitive import Primitive
-from TurtleArt.taconstants import BOX_STYLE_MEDIA, BOX_STYLE
from TurtleArt.talogo import MEDIA_BLOCKS_DICTIONARY, PLUGIN_DICTIONARY
from TurtleArt.tautils import get_path
@@ -63,7 +62,7 @@ class Camera_plugin(Plugin):
if self._status:
luminance = Primitive('luminance')
luminance.set_palette('sensor')
- luminance.set_style(BOX_STYLE)
+ luminance.set_style('box-style')
luminance.set_label(_('brightness'))
luminance.set_help(_('light level detected by camera'))
luminance.set_value_block(True)
@@ -75,7 +74,7 @@ class Camera_plugin(Plugin):
# Depreciated block
read_camera = Primitive('read_camera')
- read_camera.set_style(BOX_STYLE)
+ read_camera.set_style('box-style')
read_camera.set_label(_('brightness'))
read_camera.set_help(
_('Average RGB color from camera is pushed to the stack'))
@@ -88,7 +87,7 @@ class Camera_plugin(Plugin):
camera = Primitive('camera')
camera.set_palette('sensor')
- camera.set_style(BOX_STYLE_MEDIA)
+ camera.set_style('box-style-media')
camera.set_label([' '])
camera.set_help(_('camera output'))
camera.set_special_name(_('camera'))
diff --git a/plugins/rfid_plugin.py b/plugins/rfid_plugin.py
index 82f431a..cb1dd18 100644
--- a/plugins/rfid_plugin.py
+++ b/plugins/rfid_plugin.py
@@ -29,7 +29,6 @@ from rfid.rfidutils import strhex2bin, strbin2dec, find_device
from plugin import Plugin
from TurtleArt.taprimitive import Primitive
-from TurtleArt.taconstants import BOX_STYLE
from TurtleArt.talogo import PLUGIN_DICTIONARY
import logging
@@ -88,7 +87,7 @@ class Rfid_plugin(Plugin):
if self._status:
rfid = Primitive('rfid')
rfid.set_palette('sensor')
- rfid.set_style(BOX_STYLE)
+ rfid.set_style('box-style')
rfid.set_label(_('RFID'))
rfid.set_help(_('read value from RFID device'))
rfid.set_value_block(True)