summaryrefslogtreecommitdiff
path: root/grc/src/platforms/python
diff options
context:
space:
mode:
Diffstat (limited to 'grc/src/platforms/python')
-rw-r--r--grc/src/platforms/python/Constants.py.in12
-rw-r--r--grc/src/platforms/python/Param.py26
-rw-r--r--grc/src/platforms/python/Port.py21
3 files changed, 48 insertions, 11 deletions
diff --git a/grc/src/platforms/python/Constants.py.in b/grc/src/platforms/python/Constants.py.in
index c2d878ba3..973304eba 100644
--- a/grc/src/platforms/python/Constants.py.in
+++ b/grc/src/platforms/python/Constants.py.in
@@ -38,3 +38,15 @@ FLOW_GRAPH_TEMPLATE = os.path.join(DATA_DIR, 'flow_graph.tmpl')
BLOCK_DTD = os.path.join(DATA_DIR, 'block.dtd')
BLOCK_TREE = os.path.join(DATA_DIR, 'block_tree.xml')
DEFAULT_FLOW_GRAPH = os.path.join(DATA_DIR, 'default_flow_graph.grc.xml')
+
+#coloring
+COMPLEX_COLOR_SPEC = '#3399FF'
+FLOAT_COLOR_SPEC = '#FF8C69'
+INT_COLOR_SPEC = '#00FF99'
+SHORT_COLOR_SPEC = '#FFFF66'
+BYTE_COLOR_SPEC = '#FF66FF'
+COMPLEX_VECTOR_COLOR_SPEC = '#3399AA'
+FLOAT_VECTOR_COLOR_SPEC = '#CC8C69'
+INT_VECTOR_COLOR_SPEC = '#00CC99'
+SHORT_VECTOR_COLOR_SPEC = '#CCCC33'
+BYTE_VECTOR_COLOR_SPEC = '#CC66CC'
diff --git a/grc/src/platforms/python/Param.py b/grc/src/platforms/python/Param.py
index 39ec57e32..75098e9ed 100644
--- a/grc/src/platforms/python/Param.py
+++ b/grc/src/platforms/python/Param.py
@@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from utils import expr_utils
from .. base.Param import Param as _Param
+import Constants
import os
class Param(_Param):
@@ -36,6 +37,29 @@ class Param(_Param):
'grid_pos', 'import',
]
+ def get_color(self):
+ """
+ Get the color that represents this param's type.
+ @return a hex color code.
+ """
+ try:
+ return {
+ #number types
+ 'complex': Constants.COMPLEX_COLOR_SPEC,
+ 'real': Constants.FLOAT_COLOR_SPEC,
+ 'int': Constants.INT_COLOR_SPEC,
+ #vector types
+ 'complex_vector': Constants.COMPLEX_VECTOR_COLOR_SPEC,
+ 'real_vector': Constants.FLOAT_VECTOR_COLOR_SPEC,
+ 'int_vector': Constants.INT_VECTOR_COLOR_SPEC,
+ #special
+ 'hex': Constants.INT_COLOR_SPEC,
+ 'string': Constants.BYTE_VECTOR_COLOR_SPEC,
+ 'id': '#DDDDDD',
+ 'grid_pos': Constants.INT_VECTOR_COLOR_SPEC,
+ }[self.get_type()]
+ except: return _Param.get_color(self)
+
def get_hide(self):
"""
Get the hide value from the base class.
@@ -67,7 +91,7 @@ class Param(_Param):
def eval_string(v):
try:
e = self.get_parent().get_parent().evaluate(v)
- assert(isinstance(e, str))
+ assert isinstance(e, str)
return e
except:
self._stringify_flag = True
diff --git a/grc/src/platforms/python/Port.py b/grc/src/platforms/python/Port.py
index 93fa087eb..e75b47e4b 100644
--- a/grc/src/platforms/python/Port.py
+++ b/grc/src/platforms/python/Port.py
@@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from .. base.Port import Port as _Port
from ... import utils
+import Constants
class Port(_Port):
@@ -82,18 +83,18 @@ class Port(_Port):
try:
if self.get_vlen() == 1:
return {#vlen is 1
- 'complex': '#3399FF',
- 'float': '#FF8C69',
- 'int': '#00FF99',
- 'short': '#FFFF66',
- 'byte': '#FF66FF',
+ 'complex': Constants.COMPLEX_COLOR_SPEC,
+ 'float': Constants.FLOAT_COLOR_SPEC,
+ 'int': Constants.INT_COLOR_SPEC,
+ 'short': Constants.SHORT_COLOR_SPEC,
+ 'byte': Constants.BYTE_COLOR_SPEC,
}[self.get_type()]
return {#vlen is non 1
- 'complex': '#3399AA',
- 'float': '#CC8C69',
- 'int': '#00CC99',
- 'short': '#CCCC33',
- 'byte': '#CC66CC',
+ 'complex': Constants.COMPLEX_VECTOR_COLOR_SPEC,
+ 'float': Constants.FLOAT_VECTOR_COLOR_SPEC,
+ 'int': Constants.INT_VECTOR_COLOR_SPEC,
+ 'short': Constants.SHORT_VECTOR_COLOR_SPEC,
+ 'byte': Constants.BYTE_VECTOR_COLOR_SPEC,
}[self.get_type()]
except: return _Port.get_color(self)