]> git.gag.com Git - debian/gnuradio/blob - grc/src/grc/gui/elements/Platform.py
be11e7daea7148606e26f3a1a2db9fd2731c3224
[debian/gnuradio] / grc / src / grc / gui / elements / Platform.py
1 """
2 Copyright 2008 Free Software Foundation, Inc.
3 This file is part of GNU Radio
4
5 GNU Radio Companion is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 GNU Radio Companion 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 this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18 """
19 ##@package grc.gui.elements.Platform
20 #Graphical platform to turn an existing platform into a gui platform.
21 #@author Josh Blum
22
23 from FlowGraph import FlowGraph
24 from Connection import Connection
25 from Block import Block
26 from Port import Port
27 from Param import Param
28
29 def conjoin_classes(name, c1, c2):
30         exec("""
31 class %s(c1, c2):
32         def __init__(self, *args, **kwargs):
33                 c1.__init__(self, *args, **kwargs)
34                 c2.__init__(self, *args, **kwargs)
35 """%name, locals())
36         return locals()[name]   
37
38 def Platform(platform):
39         #combine with gui class
40         for attr, value in (
41                 ('FlowGraph', FlowGraph),
42                 ('Connection', Connection),
43                 ('Block', Block),
44                 ('Source', Port),
45                 ('Sink', Port),
46                 ('Param', Param),
47         ):
48                 old_value = getattr(platform, attr) 
49                 c = conjoin_classes(attr, old_value, value)             
50                 setattr(platform, attr, c)
51         return platform
52