summaryrefslogtreecommitdiff
path: root/gr-wxgui/grc/top_block_gui.py
diff options
context:
space:
mode:
authorJohnathan Corgan2011-03-16 08:18:30 -0700
committerJohnathan Corgan2011-03-16 08:18:30 -0700
commit4cd06fadac972d4cac559c15488bc39823063afe (patch)
tree6fe57896bc216d8c9e672194f2e4e0e75aedb645 /gr-wxgui/grc/top_block_gui.py
parent4ad736e21f45f64fd616bb53f54e45e1c63e7330 (diff)
parent1d70ed2bd928d52a383e688949cc7f747dd584fa (diff)
downloadgnuradio-4cd06fadac972d4cac559c15488bc39823063afe.tar.gz
gnuradio-4cd06fadac972d4cac559c15488bc39823063afe.tar.bz2
gnuradio-4cd06fadac972d4cac559c15488bc39823063afe.zip
Merge remote branch 'gnuradio/next'
* gnuradio/next: (806 commits) gruel: added missing ignores gruel: fixed swig interface file to dereference pmt_t. qtgui: fix distcheck error gruel: fixing structure. Passes make check. gruel: SWIGing Gruel into Python to access PMTs. gnuradio-examples: add C++ audio examples using new gr-audio created gruel/attributes.h to house compiler specific attribute macros audio: remove obsoleted individual top-level components gr-audio: added README and default config fix volk: simplify the get new method for the aligned pool grc: moved all usrp1 and usrp2 stuff out of grc and into gr-usrp*/grc grc: swap store the subprocess object rather than the pid when executing qtgui: removed python directory that was added, never used uhd: use %ignore to hide warnings and fix errors Added/updated ignore files. Fixing gr_filter_design program to import from gnuradio Python package. audio: high prio for platform specific audio osx audio: added windows and osx audio source files audio: added config checks for other audios, added jack and port audio: make prefs look like old audio, removed old audio.py ...
Diffstat (limited to 'gr-wxgui/grc/top_block_gui.py')
-rw-r--r--gr-wxgui/grc/top_block_gui.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/gr-wxgui/grc/top_block_gui.py b/gr-wxgui/grc/top_block_gui.py
new file mode 100644
index 000000000..333ccf1c1
--- /dev/null
+++ b/gr-wxgui/grc/top_block_gui.py
@@ -0,0 +1,74 @@
+# Copyright 2008, 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
+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):
+ """
+ Initialize the gr top block.
+ Create the wx gui elements.
+ @param title the main window title
+ @param size the main window size tuple in pixels
+ @param icon the file path to an icon or None
+ """
+ #initialize
+ gr.top_block.__init__(self)
+ self._size = size
+ #create gui elements
+ 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 SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs)
+
+ def Run(self, start=True):
+ """
+ Setup the wx gui elements.
+ Start the gr top block.
+ Block with the wx main loop.
+ """
+ #set minimal window size
+ self._frame.SetSizeHints(*self._size)
+ #create callback for quit
+ def _quit(event):
+ self.stop(); self.wait()
+ self._frame.Destroy()
+ #setup app
+ 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
+ if start: self.start()
+ #blocking main loop
+ self._app.MainLoop()