diff options
author | jblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-07-06 02:28:52 +0000 |
---|---|---|
committer | jblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5> | 2009-07-06 02:28:52 +0000 |
commit | 25c5d91fb7c4b54f1e7d77fd9af213a3675a8339 (patch) | |
tree | 317d2e623aa9de602197089dab6dcc4fbb17da6f /grc/grc_gnuradio | |
parent | a6396abe127c504f890d0cd45171c46ebfbb0f3d (diff) |
Merged r11309:11357 from grc branch.
Adds notebook cabability to grc and its wxgui windows/controls.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11358 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'grc/grc_gnuradio')
-rw-r--r-- | grc/grc_gnuradio/Makefile.am | 17 | ||||
-rw-r--r-- | grc/grc_gnuradio/wxgui/__init__.py | 3 | ||||
-rw-r--r-- | grc/grc_gnuradio/wxgui/panel.py | 49 | ||||
-rw-r--r-- | grc/grc_gnuradio/wxgui/top_block_gui.py | 76 |
4 files changed, 83 insertions, 62 deletions
diff --git a/grc/grc_gnuradio/Makefile.am b/grc/grc_gnuradio/Makefile.am index 9a15eb0ece..63bb72822d 100644 --- a/grc/grc_gnuradio/Makefile.am +++ b/grc/grc_gnuradio/Makefile.am @@ -23,11 +23,11 @@ include $(top_srcdir)/Makefile.common grc_gnuradio_prefix = $(pythondir)/grc_gnuradio -rootpythondir = $(grc_gnuradio_prefix) -rootpython_PYTHON = __init__.py +root_pythondir = $(grc_gnuradio_prefix) +root_python_PYTHON = __init__.py -blks2pythondir = $(grc_gnuradio_prefix)/blks2 -blks2python_PYTHON = \ +blks2_pythondir = $(grc_gnuradio_prefix)/blks2 +blks2_python_PYTHON = \ blks2/__init__.py \ blks2/error_rate.py \ blks2/packet.py \ @@ -36,14 +36,15 @@ blks2python_PYTHON = \ blks2/tcp.py \ blks2/variable_sink.py -usrppythondir = $(grc_gnuradio_prefix)/usrp -usrppython_PYTHON = \ +usrp_pythondir = $(grc_gnuradio_prefix)/usrp +usrp_python_PYTHON = \ usrp/__init__.py \ usrp/common.py \ usrp/dual_usrp.py \ usrp/simple_usrp.py -wxguipythondir = $(grc_gnuradio_prefix)/wxgui -wxguipython_PYTHON = \ +wxgui_pythondir = $(grc_gnuradio_prefix)/wxgui +wxgui_python_PYTHON = \ wxgui/__init__.py \ + wxgui/panel.py \ wxgui/top_block_gui.py diff --git a/grc/grc_gnuradio/wxgui/__init__.py b/grc/grc_gnuradio/wxgui/__init__.py index 94a0adb8a1..81427253b6 100644 --- a/grc/grc_gnuradio/wxgui/__init__.py +++ b/grc/grc_gnuradio/wxgui/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008, 2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -19,3 +19,4 @@ # from top_block_gui import top_block_gui +from panel import Panel diff --git a/grc/grc_gnuradio/wxgui/panel.py b/grc/grc_gnuradio/wxgui/panel.py new file mode 100644 index 0000000000..e62133cac2 --- /dev/null +++ b/grc/grc_gnuradio/wxgui/panel.py @@ -0,0 +1,49 @@ +# 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 wx + +class Panel(wx.Panel): + def __init__(self, parent, orient=wx.VERTICAL): + wx.Panel.__init__(self, parent) + self._box = wx.BoxSizer(orient) + self._grid = wx.GridBagSizer(5, 5) + self.Add(self._grid) + self.SetSizer(self._box) + + def GetWin(self): return self + + def Add(self, win): + """ + Add a window to the wx vbox. + @param win the wx window + """ + self._box.Add(win, 0, wx.EXPAND) + + def GridAdd(self, win, row, col, row_span=1, col_span=1): + """ + Add a window to the wx grid at the given position. + @param win the wx window + @param row the row specification (integer >= 0) + @param col the column specification (integer >= 0) + @param row_span the row span specification (integer >= 1) + @param col_span the column span specification (integer >= 1) + """ + self._grid.Add(win, wx.GBPosition(row, col), wx.GBSpan(row_span, col_span), wx.EXPAND) diff --git a/grc/grc_gnuradio/wxgui/top_block_gui.py b/grc/grc_gnuradio/wxgui/top_block_gui.py index 97bed04a57..9985758973 100644 --- a/grc/grc_gnuradio/wxgui/top_block_gui.py +++ b/grc/grc_gnuradio/wxgui/top_block_gui.py @@ -1,4 +1,4 @@ -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008, 2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,13 +21,14 @@ import wx import sys, os from gnuradio import gr +import panel default_gui_size = (200, 100) class top_block_gui(gr.top_block): """gr top block with wx gui app and grid sizer.""" - def __init__(self, title='', size=default_gui_size, icon=None): + def __init__(self, title='', size=default_gui_size): """ Initialize the gr top block. Create the wx gui elements. @@ -38,68 +39,37 @@ class top_block_gui(gr.top_block): #initialize gr.top_block.__init__(self) self._size = size - #set the icon - if icon and os.path.isfile(icon): self._icon = icon - else: self._icon = None #create gui elements - self._wx_app = wx.App() - self._wx_frame = wx.Frame(None , -1, title) - self._wx_grid = wx.GridBagSizer(5, 5) - self._wx_vbox = wx.BoxSizer(wx.VERTICAL) + self._app = wx.App() + self._frame = wx.Frame(None, title=title) + self._panel = panel.Panel(self._frame) + self.Add = self._panel.Add + self.GridAdd = self._panel.GridAdd + self.GetWin = self._panel.GetWin - def GetWin(self): - """ - Get the window for wx elements to fit within. - @return the wx frame - """ - return self._wx_frame - - def Add(self, win): - """ - Add a window to the wx vbox. - @param win the wx window - """ - self._wx_vbox.Add(win, 0, wx.EXPAND) - - def GridAdd(self, win, row, col, row_span=1, col_span=1): - """ - Add a window to the wx grid at the given position. - @param win the wx window - @param row the row specification (integer >= 0) - @param col the column specification (integer >= 0) - @param row_span the row span specification (integer >= 1) - @param col_span the column span specification (integer >= 1) - """ - self._wx_grid.Add(win, wx.GBPosition(row, col), wx.GBSpan(row_span, col_span), wx.EXPAND) - - def start(self, start=True): - if start: - gr.top_block.start(self) - else: - gr.top_block.stop(self) - gr.top_block.wait(self) + def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs) - def Run(self, autostart=True): + def Run(self, start=True): """ Setup the wx gui elements. Start the gr top block. Block with the wx main loop. """ - #set wx app icon - if self._icon: self._wx_frame.SetIcon(wx.Icon(self._icon, wx.BITMAP_TYPE_ANY)) #set minimal window size - self._wx_frame.SetSizeHints(*self._size) + self._frame.SetSizeHints(*self._size) #create callback for quit def _quit(event): - gr.top_block.stop(self) - self._wx_frame.Destroy() + self.stop(); self.wait() + self._frame.Destroy() #setup app - self._wx_vbox.Add(self._wx_grid, 0, wx.EXPAND) - self._wx_frame.Bind(wx.EVT_CLOSE, _quit) - self._wx_frame.SetSizerAndFit(self._wx_vbox) - self._wx_frame.Show() - self._wx_app.SetTopWindow(self._wx_frame) + self._frame.Bind(wx.EVT_CLOSE, _quit) + self._sizer = wx.BoxSizer(wx.VERTICAL) + self._sizer.Add(self._panel, 0, wx.EXPAND) + self._frame.SetSizerAndFit(self._sizer) + self._frame.SetAutoLayout(True) + self._frame.Show(True) + self._app.SetTopWindow(self._frame) #start flow graph - self.start(autostart) + if start: self.start() #blocking main loop - self._wx_app.MainLoop() + self._app.MainLoop() |