summaryrefslogtreecommitdiff
path: root/grc/gui/Utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'grc/gui/Utils.py')
-rw-r--r--grc/gui/Utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py
index f20e3c0fa6..51b9b19e9f 100644
--- a/grc/gui/Utils.py
+++ b/grc/gui/Utils.py
@@ -123,10 +123,11 @@ class TemplateParser(object):
parse_template = TemplateParser()
-def align_to_grid(coor):
- _align = lambda: int(round(x / (1.0 * CANVAS_GRID_SIZE)) * CANVAS_GRID_SIZE)
+def align_to_grid(coor, mode=round):
+ def align(value):
+ return int(mode(value / (1.0 * CANVAS_GRID_SIZE)) * CANVAS_GRID_SIZE)
try:
- return [_align() for x in coor]
+ return map(align, coor)
except TypeError:
x = coor
- return _align()
+ return align(coor)