From 92f2da3450b3ae0a5d16d322ad42c7812c4ffc62 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 15 Oct 2009 09:11:59 -0700 Subject: Created skeleton wxgui term window component --- gr-wxgui/src/python/termsink.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 gr-wxgui/src/python/termsink.py (limited to 'gr-wxgui/src/python/termsink.py') diff --git a/gr-wxgui/src/python/termsink.py b/gr-wxgui/src/python/termsink.py new file mode 100644 index 000000000..92aba47f4 --- /dev/null +++ b/gr-wxgui/src/python/termsink.py @@ -0,0 +1,38 @@ +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +import term_window +import common +from gnuradio import gr + +class termsink(gr.hier_block2, common.wxgui_hb): + def __init__(self,parent): + 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, + ) + -- cgit From 00613b260a36923509eab1811256815269dcd99c Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 15 Oct 2009 11:00:30 -0700 Subject: Add placeholder panel for console, use old style window size --- gr-wxgui/src/python/termsink.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gr-wxgui/src/python/termsink.py') diff --git a/gr-wxgui/src/python/termsink.py b/gr-wxgui/src/python/termsink.py index 92aba47f4..2c583b115 100644 --- a/gr-wxgui/src/python/termsink.py +++ b/gr-wxgui/src/python/termsink.py @@ -24,7 +24,10 @@ import common from gnuradio import gr class termsink(gr.hier_block2, common.wxgui_hb): - def __init__(self,parent): + def __init__(self, + parent, + ): + gr.hier_block2.__init__( self, "termsink", @@ -34,5 +37,5 @@ class termsink(gr.hier_block2, common.wxgui_hb): self.win = term_window.term_window( parent=parent, + size=term_window.DEFAULT_WIN_SIZE, ) - -- cgit From ab901e7d4cb6e5e8b1b46dac8a7af74acf72cb8c Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Wed, 21 Oct 2009 17:11:03 -0700 Subject: Basic terminal window that takes raw text on input msgq and appends it Works, but needs "--line-buffered" mode for GR buffering between blocks --- gr-wxgui/src/python/termsink.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'gr-wxgui/src/python/termsink.py') 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) -- cgit From 6f0685769f7a7728a779502435cd2dd17b8d65e2 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 29 Oct 2009 07:26:39 -0700 Subject: Consolidated termsink into one class --- gr-wxgui/src/python/termsink.py | 56 +++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'gr-wxgui/src/python/termsink.py') diff --git a/gr-wxgui/src/python/termsink.py b/gr-wxgui/src/python/termsink.py index addfa5810..45a94e396 100644 --- a/gr-wxgui/src/python/termsink.py +++ b/gr-wxgui/src/python/termsink.py @@ -19,25 +19,61 @@ # Boston, MA 02110-1301, USA. # -import term_window from gnuradio import gru +import wx -class termsink(object): +DEFAULT_WIN_SIZE = (600, 300) +APPEND_EVENT = wx.NewEventType() +EVT_APPEND_EVENT = wx.PyEventBinder(APPEND_EVENT, 0) + +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 termsink(wx.Panel): def __init__(self, parent, msgq, - size=term_window.DEFAULT_WIN_SIZE, + size=DEFAULT_WIN_SIZE, ): - - self.win = term_window.term_window( - parent=parent, - size=size, - ) + wx.Panel.__init__(self, + parent, + size=size, + style=wx.SIMPLE_BORDER, + ) + + self.text_ctrl = wx.TextCtrl(self, + wx.ID_ANY, + value="", + size=size, + style=wx.TE_MULTILINE|wx.TE_READONLY, + ) + + 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) self.runner = gru.msgq_runner(msgq, self.handle_msg) def handle_msg(self, msg): - # Just append text for now + # This gets called in the queue runner thread context + # For now, just add whatever the user sends to the text control text = msg.to_string() print "handle_msg: received", len(text), "bytes" - self.win.append_text(text) + + # Create a wxPython event and post it to the event queue + evt = AppendEvent(text) + wx.PostEvent(self, evt) + del evt + + def evt_append(self, evt): + # This gets called by the wxPython event queue runner + print "appending", len(evt.text), "bytes" + self.text_ctrl.AppendText(evt.text) -- cgit From 392b7f9002cb08dddc1ca0ced18f899a0958ba1f Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 3 Nov 2009 07:11:45 -0800 Subject: gr-wxgui: cleanup for merge --- gr-wxgui/src/python/termsink.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'gr-wxgui/src/python/termsink.py') diff --git a/gr-wxgui/src/python/termsink.py b/gr-wxgui/src/python/termsink.py index 45a94e396..a0cfd575d 100644 --- a/gr-wxgui/src/python/termsink.py +++ b/gr-wxgui/src/python/termsink.py @@ -66,7 +66,6 @@ class termsink(wx.Panel): # This gets called in the queue runner thread context # For now, just add whatever the user sends to the text control text = msg.to_string() - print "handle_msg: received", len(text), "bytes" # Create a wxPython event and post it to the event queue evt = AppendEvent(text) @@ -75,5 +74,4 @@ class termsink(wx.Panel): def evt_append(self, evt): # This gets called by the wxPython event queue runner - print "appending", len(evt.text), "bytes" self.text_ctrl.AppendText(evt.text) -- cgit