1
# Copyright 2008, 2009 Free Software Foundation, Inc.
3
# This file is part of GNU Radio
5
# GNU Radio is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3, or (at your option)
10
# GNU Radio is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with GNU Radio; see the file COPYING. If not, write to
17
# the Free Software Foundation, Inc., 51 Franklin Street,
18
# Boston, MA 02110-1301, USA.
23
from gnuradio import gr
26
default_gui_size = (200, 100)
28
class top_block_gui(gr.top_block):
29
"""gr top block with wx gui app and grid sizer."""
31
def __init__(self, title='', size=default_gui_size):
33
Initialize the gr top block.
34
Create the wx gui elements.
35
@param title the main window title
36
@param size the main window size tuple in pixels
37
@param icon the file path to an icon or None
40
gr.top_block.__init__(self)
44
self._frame = wx.Frame(None, title=title)
45
self._panel = panel.Panel(self._frame)
46
self.Add = self._panel.Add
47
self.GridAdd = self._panel.GridAdd
48
self.GetWin = self._panel.GetWin
50
def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs)
52
def Run(self, start=True):
54
Setup the wx gui elements.
55
Start the gr top block.
56
Block with the wx main loop.
58
#set minimal window size
59
self._frame.SetSizeHints(*self._size)
60
#create callback for quit
62
self.stop(); self.wait()
65
self._frame.Bind(wx.EVT_CLOSE, _quit)
66
self._sizer = wx.BoxSizer(wx.VERTICAL)
67
self._sizer.Add(self._panel, 0, wx.EXPAND)
68
self._frame.SetSizerAndFit(self._sizer)
69
self._frame.SetAutoLayout(True)
70
self._frame.Show(True)
71
self._app.SetTopWindow(self._frame)
73
if start: self.start()