Imported Upstream version 3.2.2
[debian/gnuradio] / grc / grc_gnuradio / wxgui / panel.py
1 # Copyright 2009 Free Software Foundation, Inc.
2 #
3 # This file is part of GNU Radio
4 #
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)
8 # any later version.
9 #
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.
14 #
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.
19 #
20
21 import wx
22
23 class Panel(wx.Panel):
24         def __init__(self, parent, orient=wx.VERTICAL):
25                 wx.Panel.__init__(self, parent)
26                 self._box = wx.BoxSizer(orient)
27                 self._grid = wx.GridBagSizer(5, 5)
28                 self.Add(self._grid)
29                 self.SetSizer(self._box)
30
31         def GetWin(self): return self
32
33         def Add(self, win):
34                 """
35                 Add a window to the wx vbox.
36                 @param win the wx window
37                 """
38                 self._box.Add(win, 0, wx.EXPAND)
39
40         def GridAdd(self, win, row, col, row_span=1, col_span=1):
41                 """
42                 Add a window to the wx grid at the given position.
43                 @param win the wx window
44                 @param row the row specification (integer >= 0)
45                 @param col the column specification (integer >= 0)
46                 @param row_span the row span specification (integer >= 1)
47                 @param col_span the column span specification (integer >= 1)
48                 """
49                 self._grid.Add(win, wx.GBPosition(row, col), wx.GBSpan(row_span, col_span), wx.EXPAND)