summaryrefslogtreecommitdiff
path: root/gr-wxgui
diff options
context:
space:
mode:
authorJohnathan Corgan2009-10-21 17:11:03 -0700
committerJohnathan Corgan2009-10-29 07:00:35 -0700
commitab901e7d4cb6e5e8b1b46dac8a7af74acf72cb8c (patch)
tree3da5ab0f9a121b476789f4985d09d2d39b34320d /gr-wxgui
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
Diffstat (limited to 'gr-wxgui')
-rw-r--r--gr-wxgui/src/python/term_window.py29
-rw-r--r--gr-wxgui/src/python/termsink.py26
2 files changed, 39 insertions, 16 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)