Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply changes from gr upstream #3

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions blocks/variable_struct.block.yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
parameters:
"""

FUNCTIONCALL = """\
field{0}:value{0},\
"""

TEMPLATES = """\

templates:
Expand All @@ -26,17 +30,6 @@
% endif
% endfor
}})
var_value: |-
struct({{
% for i in range({0}):
<%
field = context.get('field' + str(i))
%>
% if len(str(field)) > 2:
${{field}}: ${{field}},
% endif
% endfor
}})
"""

FIELD0 = """\
Expand Down Expand Up @@ -86,8 +79,8 @@ def make_yml(num_fields):
return ''.join((
HEADER.format(num_fields),
FIELD0, ''.join(FIELDS.format(i) for i in range(1, num_fields)),
''.join(VALUES.format(i) for i in range(num_fields)),
'value: ${value}\n\nasserts:\n',
''.join(VALUES.format(i) for i in range(num_fields)),'value: ${struct({',
''.join(FUNCTIONCALL.format(i) for i in range(num_fields)),'})}\n\nasserts:\n',
''.join(ASSERTS.format(i) for i in range(num_fields)),
''.join(TEMPLATES.format(num_fields)),
FOOTER
Expand Down
2 changes: 2 additions & 0 deletions core/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class Connection(Element):
"""

is_connection = True
category = []
documentation = {'': ''}
doc_url = ''

def __init__(self, parent, source, sink):
"""
Expand Down
2 changes: 1 addition & 1 deletion core/FlowGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _reload_variables(self, namespace: dict) -> dict:
namespace[variable_block.name] = value
# rewrite on subsequent blocks depends on an updated self.namespace
self.namespace.update(namespace)
except TypeError: # Type Errors may happen, but that doesn't matter as they are displayed in the gui
except (TypeError, FileNotFoundError): # Type Errors or FileNotFoundError may happen, but that doesn't matter as they are displayed in the gui
pass
except Exception:
log.exception(f'Failed to evaluate variable block {variable_block.name}', exc_info=True)
Expand Down
2 changes: 1 addition & 1 deletion core/ports/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def find_port(finder):
self.set_evaluated('vlen', port.vlen)
self.domain = port.domain
except AttributeError:
self.domain = Constants.DEFAULT_DOMAIN
pass

def add_clone(self):
"""
Expand Down
3 changes: 1 addition & 2 deletions gui/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class Config(CoreConfig):

name = 'GNU Radio Companion'

gui_prefs_file = os.environ.get(
'GRC_PREFS_PATH', os.path.join(get_config_file_path(), 'grc.conf'))
gui_prefs_file = os.environ.get('GRC_PREFS_PATH', get_config_file_path())

def __init__(self, install_prefix, *args, **kwargs):
CoreConfig.__init__(self, *args, **kwargs)
Expand Down
2 changes: 2 additions & 0 deletions gui/PropsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ def _update_docs_page(self):
if urlparse(url).scheme not in ("", "file"):
icon += "🌐"
self._docs_link.set_markup(f'<a href="{url}">{icon} Visit Documentation Page</a>')
elif self._block.is_connection:
self._docs_link.set_markup('Connection Properties')
else:
self._docs_link.set_markup('Out of Tree Block, No documentation URL specified')

Expand Down
3 changes: 1 addition & 2 deletions gui_qt/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class Config(CoreConfig):

name = 'GNU Radio Companion'

gui_prefs_file = os.environ.get(
'GRC_QT_PREFS_PATH', os.path.join(get_config_file_path(), 'grc_qt.conf'))
gui_prefs_file = os.environ.get('GRC_QT_PREFS_PATH', get_config_file_path('grc_qt.conf'))

def __init__(self, install_prefix, *args, **kwargs):
CoreConfig.__init__(self, *args, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion gui_qt/components/block_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def on_return_pressed(self):
self.parent.populate_tree(self.parent._block_tree)
else:
log.info(f"No block named {label}")
self.parent.reset()


def get_items(model):
Expand Down Expand Up @@ -165,7 +166,7 @@ def __init__(self):
self.populate_tree(self._block_tree)

completer = QCompleter(self._block_tree_flat.keys())
completer.setCompletionMode(QCompleter.InlineCompletion)
completer.setCompletionMode(QCompleter.PopupCompletion)
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.setFilterMode(Qt.MatchContains)
self._search_bar.setCompleter(completer)
Expand Down
4 changes: 2 additions & 2 deletions gui_qt/components/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, flowgraph):
self.buttonBox = QDialogButtonBox(buttons)
self.buttonBox.rejected.connect(self.reject) # close
self.treeview = QTreeView()
self.treeview.setEditTriggers(QTreeView.NoEditTriggers)
self.model = QStandardItemModel()
self.treeview.setModel(self.model)
self.layout = QVBoxLayout()
Expand All @@ -33,7 +34,7 @@ def __init__(self, flowgraph):

def update(self):
# TODO: Make sure the columns are wide enough
self.model = QStandardItemModel()
self.model.clear()
self.model.setHorizontalHeaderLabels(['Source', 'Aspect', 'Message'])
for element, message in self.flowgraph.iter_error_messages():
if element.is_block:
Expand All @@ -51,7 +52,6 @@ def update(self):
else:
src = aspect = QStandardItem('')
self.model.appendRow([src, aspect, QStandardItem(message)])
self.treeview.setModel(self.model)


class PropsDialog(QDialog):
Expand Down
12 changes: 9 additions & 3 deletions gui_qt/components/variable_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,15 @@ def _rebuild(self):
else:
variable_.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
if block.enabled:
variable_.setText(1, str(block.evaluate(block.value)))
variable_.setForeground(0, self._tree.palette().color(self.palette().WindowText))
variable_.setForeground(1, self._tree.palette().color(self.palette().WindowText))
try:
variable_.setText(1, str(block.evaluate(block.value)))
variable_.setForeground(0, self._tree.palette().color(self.palette().WindowText))
variable_.setForeground(1, self._tree.palette().color(self.palette().WindowText))
except Exception:
log.exception(f'Failed to evaluate variable block {block.name}', exc_info=True)
variable_.setText(1, '<Open Properties>')
variable_.setForeground(0, self._tree.palette().color(self.palette().Disabled, self.palette().WindowText))
variable_.setForeground(1, self._tree.palette().color(self.palette().Disabled, self.palette().WindowText))
else:
variable_.setText(1, '<Open Properties>')
variable_.setForeground(0, self._tree.palette().color(self.palette().Disabled, self.palette().WindowText))
Expand Down