summaryrefslogtreecommitdiff
path: root/grc/base
diff options
context:
space:
mode:
authorJosh Blum2009-08-30 10:34:10 -0700
committerJosh Blum2009-08-30 10:34:10 -0700
commit152fcbc219cd2e4f6df7b38843844bc85fdf2bc2 (patch)
tree5c94998205fb917be6e6c2d443ddf10d613fc0fb /grc/base
parentcc13a27310e4ab91ebf90ee2d9cd6e3c659e1bc0 (diff)
downloadgnuradio-152fcbc219cd2e4f6df7b38843844bc85fdf2bc2.tar.gz
gnuradio-152fcbc219cd2e4f6df7b38843844bc85fdf2bc2.tar.bz2
gnuradio-152fcbc219cd2e4f6df7b38843844bc85fdf2bc2.zip
Switched the python classes to inherit from the base and gui classes.
Use only **kwargs so all contructor parameters must be passed with keys. Moved gui input forms classes from base to gui param module.
Diffstat (limited to 'grc/base')
-rw-r--r--grc/base/Block.py8
-rw-r--r--grc/base/FlowGraph.py2
-rw-r--r--grc/base/Param.py80
-rw-r--r--grc/base/Platform.py2
4 files changed, 6 insertions, 86 deletions
diff --git a/grc/base/Block.py b/grc/base/Block.py
index 737010305..a9dae660a 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -74,16 +74,16 @@ class Block(Element):
self._params = list()
#add the id param
self.get_params().append(self.get_parent().get_parent().Param(
- self,
- odict({
+ block=self,
+ n=odict({
'name': 'ID',
'key': 'id',
'type': 'id',
})
))
self.get_params().append(self.get_parent().get_parent().Param(
- self,
- odict({
+ block=self,
+ n=odict({
'name': 'Enabled',
'key': '_enabled',
'type': 'raw',
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index 990baf029..9252f3668 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -117,7 +117,7 @@ class FlowGraph(Element):
@return the new connection
"""
self.flag()
- connection = self.get_parent().Connection(self, porta, portb)
+ connection = self.get_parent().Connection(flow_graph=self, porta=porta, portb=portb)
self.get_elements().append(connection)
return connection
diff --git a/grc/base/Param.py b/grc/base/Param.py
index 21d306592..9279e736b 100644
--- a/grc/base/Param.py
+++ b/grc/base/Param.py
@@ -19,74 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from . import odict
from Element import Element
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-class InputParam(gtk.HBox):
- """The base class for an input parameter inside the input parameters dialog."""
-
- def __init__(self, param, _handle_changed):
- gtk.HBox.__init__(self)
- self.param = param
- self._handle_changed = _handle_changed
- self.label = gtk.Label('') #no label, markup is added by set_markup
- self.label.set_size_request(150, -1)
- self.pack_start(self.label, False)
- self.set_markup = lambda m: self.label.set_markup(m)
- self.tp = None
- def set_color(self, color): pass
-
-class EntryParam(InputParam):
- """Provide an entry box for strings and numbers."""
-
- def __init__(self, *args, **kwargs):
- InputParam.__init__(self, *args, **kwargs)
- self.entry = input = gtk.Entry()
- input.set_text(self.param.get_value())
- input.connect('changed', self._handle_changed)
- self.pack_start(input, True)
- self.get_text = input.get_text
- #tool tip
- self.tp = gtk.Tooltips()
- self.tp.set_tip(self.entry, '')
- self.tp.enable()
- def set_color(self, color): self.entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
-
-class EnumParam(InputParam):
- """Provide an entry box for Enum types with a drop down menu."""
-
- def __init__(self, *args, **kwargs):
- InputParam.__init__(self, *args, **kwargs)
- self._input = gtk.combo_box_new_text()
- for option in self.param.get_options(): self._input.append_text(option.get_name())
- self._input.set_active(self.param.get_option_keys().index(self.param.get_value()))
- self._input.connect('changed', self._handle_changed)
- self.pack_start(self._input, False)
- def get_text(self): return self.param.get_option_keys()[self._input.get_active()]
-
-class EnumEntryParam(InputParam):
- """Provide an entry box and drop down menu for Raw Enum types."""
-
- def __init__(self, *args, **kwargs):
- InputParam.__init__(self, *args, **kwargs)
- self._input = gtk.combo_box_entry_new_text()
- for option in self.param.get_options(): self._input.append_text(option.get_name())
- try: self._input.set_active(self.param.get_option_keys().index(self.param.get_value()))
- except:
- self._input.set_active(-1)
- self._input.get_child().set_text(self.param.get_value())
- self._input.connect('changed', self._handle_changed)
- self._input.get_child().connect('changed', self._handle_changed)
- self.pack_start(self._input, False)
- def get_text(self):
- if self._input.get_active() == -1: return self._input.get_child().get_text()
- return self.param.get_option_keys()[self._input.get_active()]
- def set_color(self, color):
- if self._input.get_active() == -1: #custom entry, use color
- self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color))
- else: #from enum, make white background
- self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
def _get_keys(lst): return [elem.get_key() for elem in lst]
def _get_elem(lst, key):
@@ -231,18 +163,6 @@ class Param(Element):
if self.is_enum(): return self.get_option(self.get_value()).get_name()
return self.get_value()
- def get_input_class(self):
- """
- Get the graphical gtk class to represent this parameter.
- An enum requires and combo parameter.
- A non-enum with options gets a combined entry/combo parameter.
- All others get a standard entry parameter.
- @return gtk input class
- """
- if self.is_enum(): return EnumParam
- if self.get_options(): return EnumEntryParam
- return EntryParam
-
##############################################
# Access Options
##############################################
diff --git a/grc/base/Platform.py b/grc/base/Platform.py
index db7ade9a3..51a3b2f87 100644
--- a/grc/base/Platform.py
+++ b/grc/base/Platform.py
@@ -146,7 +146,7 @@ class Platform(_Element):
def is_platform(self): return True
- def get_new_flow_graph(self): return self.FlowGraph(self)
+ def get_new_flow_graph(self): return self.FlowGraph(platform=self)
def get_generator(self): return self._generator