~ubuntu-branches/ubuntu/trusty/gnuradio/trusty-updates

« back to all changes in this revision

Viewing changes to grc/grc_gnuradio/wxgui/top_block_gui.py

  • Committer: Package Import Robot
  • Author(s): A. Maitland Bottoms
  • Date: 2012-02-26 21:26:16 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120226212616-vsfkbi1158xshdql
Tags: 3.5.1-1
* new upstream version, re-packaged from scratch with modern tools
    closes: #642716, #645332, #394849, #616832, #590048, #642580,
    #647018, #557050, #559640, #631863
* CMake build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2008, 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
 
import sys, os
23
 
from gnuradio import gr
24
 
import panel
25
 
 
26
 
default_gui_size = (200, 100)
27
 
 
28
 
class top_block_gui(gr.top_block):
29
 
        """gr top block with wx gui app and grid sizer."""
30
 
 
31
 
        def __init__(self, title='', size=default_gui_size):
32
 
                """
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
38
 
                """
39
 
                #initialize
40
 
                gr.top_block.__init__(self)
41
 
                self._size = size
42
 
                #create gui elements
43
 
                self._app = wx.App()
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
49
 
 
50
 
        def SetIcon(self, *args, **kwargs): self._frame.SetIcon(*args, **kwargs)
51
 
 
52
 
        def Run(self, start=True):
53
 
                """
54
 
                Setup the wx gui elements.
55
 
                Start the gr top block.
56
 
                Block with the wx main loop.
57
 
                """
58
 
                #set minimal window size
59
 
                self._frame.SetSizeHints(*self._size)
60
 
                #create callback for quit
61
 
                def _quit(event):
62
 
                        self.stop(); self.wait()
63
 
                        self._frame.Destroy()
64
 
                #setup app
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)
72
 
                #start flow graph
73
 
                if start: self.start()
74
 
                #blocking main loop
75
 
                self._app.MainLoop()