commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/03: grc: random block placement to accou


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/03: grc: random block placement to account for small canvas vs screen size
Date: Mon, 6 Jun 2016 17:15:25 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit 49e1f51d7943aab7cb63524499e046c81856198f
Author: Glenn Richardson <address@hidden>
Date:   Mon May 30 22:08:49 2016 -0400

    grc: random block placement to account for small canvas vs screen size
---
 grc/gui/FlowGraph.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 2053e86..cfaa6a0 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]