2 # Copyright 2004 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
22 '''A simple wx gui for GNU Radio applications'''
26 from gnuradio import gr
29 class stdapp (wx.App):
30 def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2):
31 self.top_block_maker = top_block_maker
33 self._nstatus = nstatus
34 # All our initialization must come before calling wx.App.__init__.
35 # OnInit is called from somewhere in the guts of __init__.
36 wx.App.__init__ (self, redirect=False)
39 frame = stdframe (self.top_block_maker, self.title, self._nstatus)
41 self.SetTopWindow (frame)
45 class stdframe (wx.Frame):
46 def __init__ (self, top_block_maker, title="GNU Radio", nstatus=2):
47 # print "stdframe.__init__"
48 wx.Frame.__init__(self, None, -1, title)
50 self.CreateStatusBar (nstatus)
51 mainmenu = wx.MenuBar ()
54 item = menu.Append (200, 'E&xit', 'Exit')
55 self.Bind (wx.EVT_MENU, self.OnCloseWindow, item)
56 mainmenu.Append (menu, "&File")
57 self.SetMenuBar (mainmenu)
59 self.Bind (wx.EVT_CLOSE, self.OnCloseWindow)
60 self.panel = stdpanel (self, self, top_block_maker)
61 vbox = wx.BoxSizer(wx.VERTICAL)
62 vbox.Add(self.panel, 1, wx.EXPAND)
64 self.SetAutoLayout(True)
67 def OnCloseWindow (self, event):
68 self.top_block().stop()
72 return self.panel.top_block
74 class stdpanel (wx.Panel):
75 def __init__ (self, parent, frame, top_block_maker):
76 # print "stdpanel.__init__"
77 wx.Panel.__init__ (self, parent, -1)
80 vbox = wx.BoxSizer (wx.VERTICAL)
81 self.top_block = top_block_maker (frame, self, vbox, sys.argv)
83 self.SetAutoLayout (True)
86 self.top_block.start ()
88 class std_top_block (gr.top_block):
89 def __init__ (self, parent, panel, vbox, argv):
90 # Call the hier_block2 constructor
91 # Top blocks have no inputs and outputs
92 gr.top_block.__init__(self, "std_top_block")