diff options
author | Glenn Richardson <glenn.richardson@live.com> | 2016-05-30 22:08:49 -0400 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2016-05-31 09:37:51 +0200 |
commit | 49e1f51d7943aab7cb63524499e046c81856198f (patch) | |
tree | 1e8dd4351a3f79da85802a6164181488bf0fe281 /grc/gui/FlowGraph.py | |
parent | 23460e36094ad85c559a538918c3b40e76b2fa37 (diff) |
grc: random block placement to account for small canvas vs screen size
Diffstat (limited to 'grc/gui/FlowGraph.py')
-rw-r--r-- | grc/gui/FlowGraph.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index 2053e86454..cfaa6a0c0e 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -124,11 +124,14 @@ class FlowGraph(Element): """ id = self._get_unique_id(key) #calculate the position coordinate + W, H = self.get_size() h_adj = self.get_scroll_pane().get_hadjustment() v_adj = self.get_scroll_pane().get_vadjustment() if coor is None: coor = ( - int(random.uniform(.25, .75)*h_adj.page_size + h_adj.get_value()), - int(random.uniform(.25, .75)*v_adj.page_size + v_adj.get_value()), + int(random.uniform(.25, .75) * min(h_adj.page_size, W) + + h_adj.get_value()), + int(random.uniform(.25, .75) * min(v_adj.page_size, H) + + v_adj.get_value()), ) #get the new block block = self.get_new_block(key) |