summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan2009-10-21 17:11:03 -0700
committerJohnathan Corgan2009-10-29 07:00:35 -0700
commitab901e7d4cb6e5e8b1b46dac8a7af74acf72cb8c (patch)
tree3da5ab0f9a121b476789f4985d09d2d39b34320d
parent00613b260a36923509eab1811256815269dcd99c (diff)
downloadgnuradio-ab901e7d4cb6e5e8b1b46dac8a7af74acf72cb8c.tar.gz
gnuradio-ab901e7d4cb6e5e8b1b46dac8a7af74acf72cb8c.tar.bz2
gnuradio-ab901e7d4cb6e5e8b1b46dac8a7af74acf72cb8c.zip
Basic terminal window that takes raw text on input msgq and appends it
Works, but needs "--line-buffered" mode for GR buffering between blocks
-rw-r--r--gr-wxgui/src/python/term_window.py29
-rw-r--r--gr-wxgui/src/python/termsink.py26
-rw-r--r--grc/blocks/wxgui_termsink.xml25
3 files changed, 63 insertions, 17 deletions
diff --git a/gr-wxgui/src/python/term_window.py b/gr-wxgui/src/python/term_window.py
index 8658e54a6..77270b1f3 100644
--- a/gr-wxgui/src/python/term_window.py
+++ b/gr-wxgui/src/python/term_window.py
@@ -20,17 +20,27 @@
#
import wx
-import pubsub
DEFAULT_WIN_SIZE = (600, 300)
+APPEND_EVENT = wx.NewEventType()
+EVT_APPEND_EVENT = wx.PyEventBinder(APPEND_EVENT, 0)
-class term_window(wx.Panel, pubsub.pubsub):
+class AppendEvent(wx.PyEvent):
+ def __init__(self, text):
+ wx.PyEvent.__init__(self)
+ self.SetEventType(APPEND_EVENT)
+ self.text = text
+
+ def Clone(self):
+ self.__class__(self.GetId())
+
+
+class term_window(wx.Panel):
def __init__(self,
parent,
size,
):
- pubsub.pubsub.__init__(self)
wx.Panel.__init__(self,
parent,
size=size,
@@ -39,7 +49,7 @@ class term_window(wx.Panel, pubsub.pubsub):
self.text_ctrl = wx.TextCtrl(self,
wx.ID_ANY,
- value="BOO",
+ value="",
size=size,
style=wx.TE_MULTILINE|wx.TE_READONLY,
)
@@ -47,3 +57,14 @@ class term_window(wx.Panel, pubsub.pubsub):
main_sizer = wx.BoxSizer(wx.VERTICAL)
main_sizer.Add(self.text_ctrl, 1, wx.EXPAND)
self.SetSizerAndFit(main_sizer)
+
+ EVT_APPEND_EVENT(self, self.evt_append)
+
+ def append_text(self, text):
+ evt = AppendEvent(text)
+ wx.PostEvent(self, evt)
+ del evt
+
+ def evt_append(self, evt):
+ print "appending", len(evt.text), "bytes"
+ self.text_ctrl.AppendText(evt.text)
diff --git a/gr-wxgui/src/python/termsink.py b/gr-wxgui/src/python/termsink.py
index 2c583b115..addfa5810 100644
--- a/gr-wxgui/src/python/termsink.py
+++ b/gr-wxgui/src/python/termsink.py
@@ -20,22 +20,24 @@
#
import term_window
-import common
-from gnuradio import gr
+from gnuradio import gru
-class termsink(gr.hier_block2, common.wxgui_hb):
+class termsink(object):
def __init__(self,
parent,
+ msgq,
+ size=term_window.DEFAULT_WIN_SIZE,
):
-
- gr.hier_block2.__init__(
- self,
- "termsink",
- gr.io_signature(0, 0, 0),
- gr.io_signature(0, 0, 0),
- )
-
+
self.win = term_window.term_window(
parent=parent,
- size=term_window.DEFAULT_WIN_SIZE,
+ size=size,
)
+
+ self.runner = gru.msgq_runner(msgq, self.handle_msg)
+
+ def handle_msg(self, msg):
+ # Just append text for now
+ text = msg.to_string()
+ print "handle_msg: received", len(text), "bytes"
+ self.win.append_text(text)
diff --git a/grc/blocks/wxgui_termsink.xml b/grc/blocks/wxgui_termsink.xml
index e1d52cd17..fce7577de 100644
--- a/grc/blocks/wxgui_termsink.xml
+++ b/grc/blocks/wxgui_termsink.xml
@@ -7,26 +7,49 @@
<block>
<name>Terminal Sink</name>
<key>wxgui_termsink</key>
+
<import>from gnuradio.wxgui import termsink</import>
+
<make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
termsink.termsink(
- $(parent).GetWin(),
+ parent=$(parent).GetWin(),
+#if $win_size()
+ size=$win_size,
+#end if
+ msgq=$(id)_msgq,
)
#if not $grid_pos()
$(parent).Add(self.$(id).win)
#else
$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
#end if</make>
+
+ <param>
+ <name>Window Size</name>
+ <key>win_size</key>
+ <value></value>
+ <type>int_vector</type>
+ <hide>#if $win_size() then 'none' else 'part'#</hide>
+ </param>
<param>
<name>Grid Position</name>
<key>grid_pos</key>
<value></value>
<type>grid_pos</type>
</param>
+
<param>
<name>Notebook</name>
<key>notebook</key>
<value></value>
<type>notebook</type>
</param>
+
+ <check>not $win_size or len($win_size) == 2</check>
+
+ <sink>
+ <name>in</name>
+ <type>msg</type>
+ </sink>
+
</block>