summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
authorJosh Morman <jmorman@gnuradio.org>2021-11-24 12:48:20 -0500
committermormj <34754695+mormj@users.noreply.github.com>2021-11-24 14:41:53 -0500
commit817fc3ce9cdc819a291e76ec324c4e748381f035 (patch)
treeed00faf5ea2c0f5a8caaba0ce41cd816dd6ca958 /grc/gui
parente776d673aa51b5ef19e16cfb6d22098c0b14a679 (diff)
grc: pep8 formatting
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/Actions.py46
-rw-r--r--grc/gui/Application.py97
-rw-r--r--grc/gui/Bars.py42
-rw-r--r--grc/gui/BlockTreeWindow.py61
-rw-r--r--grc/gui/Config.py7
-rw-r--r--grc/gui/Console.py10
-rw-r--r--grc/gui/Constants.py10
-rw-r--r--grc/gui/Dialogs.py15
-rw-r--r--grc/gui/DrawingArea.py4
-rw-r--r--grc/gui/Executor.py3
-rw-r--r--grc/gui/FileDialogs.py24
-rw-r--r--grc/gui/MainWindow.py101
-rw-r--r--grc/gui/Notebook.py9
-rw-r--r--grc/gui/ParamWidgets.py46
-rw-r--r--grc/gui/ParserErrorsDialog.py11
-rw-r--r--grc/gui/PropsDialog.py15
-rw-r--r--grc/gui/StateCache.py15
-rw-r--r--grc/gui/Utils.py14
-rw-r--r--grc/gui/VariableEditor.py72
-rw-r--r--grc/gui/__init__.py1
-rw-r--r--grc/gui/canvas/block.py38
-rw-r--r--grc/gui/canvas/colors.py8
-rw-r--r--grc/gui/canvas/connection.py15
-rw-r--r--grc/gui/canvas/flowgraph.py66
-rw-r--r--grc/gui/canvas/param.py12
-rw-r--r--grc/gui/canvas/port.py13
26 files changed, 466 insertions, 289 deletions
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index 1d815cc533..3c312f6505 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -85,10 +85,10 @@ class Namespace(object):
key = "{}.{}".format(prefix, name)
if prefix == "app":
pass
- #self.app.add_action(action)
+ # self.app.add_action(action)
elif prefix == "win":
pass
- #self.win.add_action(action)
+ # self.win.add_action(action)
#log.debug("Registering action as '{}'".format(key))
self._actions[key] = action
@@ -132,7 +132,7 @@ class Namespace(object):
class Action(Gio.SimpleAction):
# Change these to normal python properties.
- #prefs_name
+ # prefs_name
def __init__(self,
name,
@@ -295,7 +295,7 @@ FLOW_GRAPH_DUPLICATE = actions.register(
"app.flowgraph.duplicate",
label='_Duplicate',
tooltip='Create a duplicate of current flow graph',
- #stock_id=Gtk.STOCK_COPY,
+ # stock_id=Gtk.STOCK_COPY,
keypresses=["<Ctrl><Shift>d"],
)
FLOW_GRAPH_CLOSE = actions.register(
@@ -433,26 +433,27 @@ BLOCK_BYPASS = actions.register(
keypresses=["b"],
)
ZOOM_IN = actions.register("win.zoom_in",
- label='Zoom In',
- tooltip='Increase the canvas zoom level',
- keypresses=["<Ctrl>plus","<Ctrl>equal","<Ctrl>KP_Add"],
-)
+ label='Zoom In',
+ tooltip='Increase the canvas zoom level',
+ keypresses=["<Ctrl>plus",
+ "<Ctrl>equal", "<Ctrl>KP_Add"],
+ )
ZOOM_OUT = actions.register("win.zoom_out",
- label='Zoom Out',
- tooltip='Decrease the canvas zoom level',
- keypresses=["<Ctrl>minus","<Ctrl>KP_Subtract"],
-)
+ label='Zoom Out',
+ tooltip='Decrease the canvas zoom level',
+ keypresses=["<Ctrl>minus", "<Ctrl>KP_Subtract"],
+ )
ZOOM_RESET = actions.register("win.zoom_reset",
- label='Reset Zoom',
- tooltip='Reset the canvas zoom level',
- keypresses=["<Ctrl>0","<Ctrl>KP_0"],
-)
+ label='Reset Zoom',
+ tooltip='Reset the canvas zoom level',
+ keypresses=["<Ctrl>0", "<Ctrl>KP_0"],
+ )
TOGGLE_SNAP_TO_GRID = actions.register("win.snap_to_grid",
- label='_Snap to grid',
- tooltip='Snap blocks to a grid for an easier connection alignment',
- preference_name='snap_to_grid',
- default=True,
-)
+ label='_Snap to grid',
+ tooltip='Snap blocks to a grid for an easier connection alignment',
+ preference_name='snap_to_grid',
+ default=True,
+ )
TOGGLE_HIDE_DISABLED_BLOCKS = actions.register(
"win.hide_disabled",
label='Hide _Disabled Blocks',
@@ -493,8 +494,7 @@ TOGGLE_SHOW_BLOCK_IDS = actions.register(
TOGGLE_FLOW_GRAPH_VAR_EDITOR = actions.register(
"win.toggle_variable_editor",
label='Show _Variable Editor',
- tooltip=
- 'Show the variable editor. Modify variables and imports in this flow graph',
+ tooltip='Show the variable editor. Modify variables and imports in this flow graph',
icon_name='accessories-text-editor',
default=True,
keypresses=["<Ctrl>e"],
diff --git a/grc/gui/Application.py b/grc/gui/Application.py
index 1996d66c1e..87c5cf0ed8 100644
--- a/grc/gui/Application.py
+++ b/grc/gui/Application.py
@@ -7,7 +7,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
"""
-
import logging
import os
import subprocess
@@ -65,7 +64,8 @@ class Application(Gtk.Application):
self.set_accels_for_action(x, keypress)
# Initialize
- self.init_file_paths = [os.path.abspath(file_path) for file_path in file_paths]
+ self.init_file_paths = [os.path.abspath(
+ file_path) for file_path in file_paths]
self.init = False
def do_startup(self):
@@ -80,7 +80,7 @@ class Application(Gtk.Application):
self.main_window.connect('delete-event', self._quit)
self.get_focus_flag = self.main_window.get_focus_flag
- #setup the messages
+ # setup the messages
Messages.register_messenger(self.main_window.add_console_line)
Messages.send_init(self.platform)
@@ -117,7 +117,8 @@ class Application(Gtk.Application):
file_path_to_show = self.config.file_open()
for file_path in (self.init_file_paths or self.config.get_open_files()):
if os.path.exists(file_path):
- main.new_page(file_path, show=file_path_to_show == file_path)
+ main.new_page(
+ file_path, show=file_path_to_show == file_path)
if not main.current_page:
main.new_page() # ensure that at least a blank page exists
@@ -190,9 +191,12 @@ class Application(Gtk.Application):
action.load_from_preferences()
# Hide the panels *IF* it's saved in preferences
- main.update_panel_visibility(main.BLOCKS, Actions.TOGGLE_BLOCKS_WINDOW.get_active())
- main.update_panel_visibility(main.CONSOLE, Actions.TOGGLE_CONSOLE_WINDOW.get_active())
- main.update_panel_visibility(main.VARIABLES, Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR.get_active())
+ main.update_panel_visibility(
+ main.BLOCKS, Actions.TOGGLE_BLOCKS_WINDOW.get_active())
+ main.update_panel_visibility(
+ main.CONSOLE, Actions.TOGGLE_CONSOLE_WINDOW.get_active())
+ main.update_panel_visibility(
+ main.VARIABLES, Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR.get_active())
# Force an update on the current page to match loaded preferences.
# In the future, change the __init__ order to load preferences first
@@ -210,7 +214,7 @@ class Application(Gtk.Application):
# Selections
##################################################
elif action == Actions.ELEMENT_SELECT:
- pass #do nothing, update routines below
+ pass # do nothing, update routines below
elif action == Actions.NOTHING_SELECT:
flow_graph.unselect()
elif action == Actions.SELECT_ALL:
@@ -271,7 +275,6 @@ class Application(Gtk.Application):
x_min = min(block.coordinate[0] for block in selected_blocks)
y_min = min(block.coordinate[1] for block in selected_blocks)
-
for connection in flow_graph.connections:
# Get id of connected blocks
@@ -283,7 +286,8 @@ class Application(Gtk.Application):
pads.append({
'key': connection.sink_port.key,
'coord': source.coordinate,
- 'block_index': selected_blocks.index(sink) + 1, # Ignore the options block
+ # Ignore the options block
+ 'block_index': selected_blocks.index(sink) + 1,
'direction': 'source'
})
@@ -292,7 +296,8 @@ class Application(Gtk.Application):
pads.append({
'key': connection.source_port.key,
'coord': sink.coordinate,
- 'block_index': selected_blocks.index(source) + 1, # Ignore the options block
+ # Ignore the options block
+ 'block_index': selected_blocks.index(source) + 1,
'direction': 'sink'
})
@@ -335,7 +340,8 @@ class Application(Gtk.Application):
pad_block = flow_graph.get_block(pad_id)
pad_sink = pad_block.sinks[0]
- source_block = flow_graph.get_block(flow_graph.blocks[pad['block_index']].name)
+ source_block = flow_graph.get_block(
+ flow_graph.blocks[pad['block_index']].name)
source = source_block.get_source(pad['key'])
# ensure the port types match
@@ -350,13 +356,15 @@ class Application(Gtk.Application):
new_connection = flow_graph.connect(source, pad_sink)
elif pad['direction'] == 'source':
- pad_id = flow_graph.add_new_block('pad_source', pad['coord'])
+ pad_id = flow_graph.add_new_block(
+ 'pad_source', pad['coord'])
# setup the references to the sink and source
pad_block = flow_graph.get_block(pad_id)
pad_source = pad_block.sources[0]
- sink_block = flow_graph.get_block(flow_graph.blocks[pad['block_index']].name)
+ sink_block = flow_graph.get_block(
+ flow_graph.blocks[pad['block_index']].name)
sink = sink_block.get_sink(pad['key'])
# ensure the port types match
@@ -496,7 +504,8 @@ class Application(Gtk.Application):
# to be visible.
varedit = Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR
if active:
- log.debug("Variables are hidden. Forcing the variable panel to be visible.")
+ log.debug(
+ "Variables are hidden. Forcing the variable panel to be visible.")
varedit.disable()
else:
varedit.enable()
@@ -548,8 +557,9 @@ class Application(Gtk.Application):
while response == Gtk.ResponseType.APPLY: # rerun the dialog if Apply was hit
response = self.dialog.run()
if response in (Gtk.ResponseType.APPLY, Gtk.ResponseType.ACCEPT):
- page.state_cache.save_new_state(flow_graph.export_data())
- ### Following line forces a complete update of io ports
+ page.state_cache.save_new_state(
+ flow_graph.export_data())
+ # Following line forces a complete update of io ports
flow_graph_update()
page.saved = False
if response in (Gtk.ResponseType.REJECT, Gtk.ResponseType.ACCEPT):
@@ -600,18 +610,21 @@ class Application(Gtk.Application):
main.new_page()
args = (GLib.Variant('s', 'qt_gui'),)
flow_graph = main.current_page.flow_graph
- flow_graph.options_block.params['generate_options'].set_value(str(args[0])[1:-1])
+ flow_graph.options_block.params['generate_options'].set_value(str(args[0])[
+ 1:-1])
flow_graph.options_block.params['author'].set_value(getuser())
flow_graph_update(flow_graph)
elif action == Actions.FLOW_GRAPH_NEW_TYPE:
main.new_page()
if args:
flow_graph = main.current_page.flow_graph
- flow_graph.options_block.params['generate_options'].set_value(str(args[0])[1:-1])
+ flow_graph.options_block.params['generate_options'].set_value(str(args[0])[
+ 1:-1])
flow_graph_update(flow_graph)
elif action == Actions.FLOW_GRAPH_OPEN:
- file_paths = args[0] if args[0] else FileDialogs.OpenFlowGraph(main, page.file_path).run()
- if file_paths: # Open a new page for each file, show only the first
+ file_paths = args[0] if args[0] else FileDialogs.OpenFlowGraph(
+ main, page.file_path).run()
+ if file_paths: # Open a new page for each file, show only the first
for i, file_path in enumerate(file_paths):
main.new_page(file_path, show=(i == 0))
self.config.add_recent_file(file_path)
@@ -631,10 +644,10 @@ class Application(Gtk.Application):
main.tool_bar.refresh_submenus()
main.menu.refresh_submenus()
elif action == Actions.FLOW_GRAPH_SAVE:
- #read-only or undefined file path, do save-as
+ # read-only or undefined file path, do save-as
if page.get_read_only() or not page.file_path:
Actions.FLOW_GRAPH_SAVE_AS()
- #otherwise try to save
+ # otherwise try to save
else:
try:
self.platform.save_flow_graph(page.file_path, flow_graph)
@@ -670,18 +683,25 @@ class Application(Gtk.Application):
Actions.FLOW_GRAPH_SAVE_AS()
else:
dup_file_path = page.file_path
- dup_file_name = '.'.join(dup_file_path.split('.')[:-1]) + "_copy" # Assuming .grc extension at the end of file_path
+ # Assuming .grc extension at the end of file_path
+ dup_file_name = '.'.join(
+ dup_file_path.split('.')[:-1]) + "_copy"
dup_file_path_temp = dup_file_name + Constants.FILE_EXTENSION
count = 1
while os.path.exists(dup_file_path_temp):
- dup_file_path_temp = '{}({}){}'.format(dup_file_name, count, Constants.FILE_EXTENSION)
+ dup_file_path_temp = '{}({}){}'.format(
+ dup_file_name, count, Constants.FILE_EXTENSION)
count += 1
- dup_file_path_user = FileDialogs.SaveFlowGraph(main, dup_file_path_temp).run()
+ dup_file_path_user = FileDialogs.SaveFlowGraph(
+ main, dup_file_path_temp).run()
if dup_file_path_user is not None:
- self.platform.save_flow_graph(dup_file_path_user, flow_graph)
- Messages.send('Saved Copy to: "' + dup_file_path_user + '"\n')
+ self.platform.save_flow_graph(
+ dup_file_path_user, flow_graph)
+ Messages.send('Saved Copy to: "' +
+ dup_file_path_user + '"\n')
except IOError:
- Messages.send_fail_save("Can not create a copy of the flowgraph\n")
+ Messages.send_fail_save(
+ "Can not create a copy of the flowgraph\n")
elif action == Actions.FLOW_GRAPH_DUPLICATE:
previous = flow_graph
# Create a new page
@@ -694,10 +714,12 @@ class Application(Gtk.Application):
page.state_cache.save_new_state(new_flow_graph.export_data())
page.saved = False
elif action == Actions.FLOW_GRAPH_SCREEN_CAPTURE:
- file_path, background_transparent = FileDialogs.SaveScreenShot(main, page.file_path).run()
+ file_path, background_transparent = FileDialogs.SaveScreenShot(
+ main, page.file_path).run()
if file_path is not None:
try:
- Utils.make_screenshot(flow_graph, file_path, background_transparent)
+ Utils.make_screenshot(
+ flow_graph, file_path, background_transparent)
except ValueError:
Messages.send('Failed to generate screen shot\n')
##################################################
@@ -717,7 +739,6 @@ class Application(Gtk.Application):
except Exception as e:
Messages.send_fail_gen(e)
-
elif action == Actions.FLOW_GRAPH_EXEC:
if not page.process:
Actions.FLOW_GRAPH_GEN()
@@ -734,7 +755,7 @@ class Application(Gtk.Application):
flow_graph_page=page,
xterm_executable=xterm,
callback=self.update_exec_stop
- )
+ )
elif action == Actions.FLOW_GRAPH_KILL:
if page.process:
try:
@@ -748,7 +769,7 @@ class Application(Gtk.Application):
self.platform.build_library()
main.btwin.repopulate()
- #todo: implement parser error dialog for YAML
+ # todo: implement parser error dialog for YAML
# Force a redraw of the graph, by getting the current state and re-importing it
main.update_pages()
@@ -791,21 +812,21 @@ class Application(Gtk.Application):
selected_blocks = list(flow_graph.selected_blocks())
selected_block = selected_blocks[0] if selected_blocks else None
- #update general buttons
+ # update general buttons
Actions.ERRORS_WINDOW_DISPLAY.set_enabled(not flow_graph.is_valid())
Actions.ELEMENT_DELETE.set_enabled(bool(flow_graph.selected_elements))
Actions.BLOCK_PARAM_MODIFY.set_enabled(bool(selected_block))
Actions.BLOCK_ROTATE_CCW.set_enabled(bool(selected_blocks))
Actions.BLOCK_ROTATE_CW.set_enabled(bool(selected_blocks))
- #update alignment options
+ # update alignment options
for act in Actions.BLOCK_ALIGNMENTS:
if act:
act.set_enabled(len(selected_blocks) > 1)
- #update cut/copy/paste
+ # update cut/copy/paste
Actions.BLOCK_CUT.set_enabled(bool(selected_blocks))
Actions.BLOCK_COPY.set_enabled(bool(selected_blocks))
Actions.BLOCK_PASTE.set_enabled(bool(self.clipboard))
- #update enable/disable/bypass
+ # update enable/disable/bypass
can_enable = any(block.state != 'enabled'
for block in selected_blocks)
can_disable = any(block.state != 'disabled'
diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py
index 86eb3a5716..84867a8b4c 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -42,11 +42,14 @@ TOOLBAR_LIST = [
(Actions.FLOW_GRAPH_OPEN, 'flow_graph_recent'),
Actions.FLOW_GRAPH_SAVE, Actions.FLOW_GRAPH_CLOSE],
[Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR, Actions.FLOW_GRAPH_SCREEN_CAPTURE],
- [Actions.BLOCK_CUT, Actions.BLOCK_COPY, Actions.BLOCK_PASTE, Actions.ELEMENT_DELETE],
+ [Actions.BLOCK_CUT, Actions.BLOCK_COPY,
+ Actions.BLOCK_PASTE, Actions.ELEMENT_DELETE],
[Actions.FLOW_GRAPH_UNDO, Actions.FLOW_GRAPH_REDO],
- [Actions.ERRORS_WINDOW_DISPLAY, Actions.FLOW_GRAPH_GEN, Actions.FLOW_GRAPH_EXEC, Actions.FLOW_GRAPH_KILL],
+ [Actions.ERRORS_WINDOW_DISPLAY, Actions.FLOW_GRAPH_GEN,
+ Actions.FLOW_GRAPH_EXEC, Actions.FLOW_GRAPH_KILL],
[Actions.BLOCK_ROTATE_CCW, Actions.BLOCK_ROTATE_CW],
- [Actions.BLOCK_ENABLE, Actions.BLOCK_DISABLE, Actions.BLOCK_BYPASS, Actions.TOGGLE_HIDE_DISABLED_BLOCKS],
+ [Actions.BLOCK_ENABLE, Actions.BLOCK_DISABLE,
+ Actions.BLOCK_BYPASS, Actions.TOGGLE_HIDE_DISABLED_BLOCKS],
[Actions.FIND_BLOCKS, Actions.RELOAD_BLOCKS, Actions.OPEN_HIER]
]
@@ -56,23 +59,28 @@ MENU_BAR_LIST = [
('_File', [
[(Actions.FLOW_GRAPH_NEW, 'flow_graph_new_type'), Actions.FLOW_GRAPH_DUPLICATE,
Actions.FLOW_GRAPH_OPEN, (Actions.FLOW_GRAPH_OPEN_RECENT, 'flow_graph_recent')],
- [Actions.FLOW_GRAPH_SAVE, Actions.FLOW_GRAPH_SAVE_AS, Actions.FLOW_GRAPH_SAVE_COPY],
+ [Actions.FLOW_GRAPH_SAVE, Actions.FLOW_GRAPH_SAVE_AS,
+ Actions.FLOW_GRAPH_SAVE_COPY],
[Actions.FLOW_GRAPH_SCREEN_CAPTURE],
[Actions.FLOW_GRAPH_CLOSE, Actions.APPLICATION_QUIT]
]),
('_Edit', [
[Actions.FLOW_GRAPH_UNDO, Actions.FLOW_GRAPH_REDO],
- [Actions.BLOCK_CUT, Actions.BLOCK_COPY, Actions.BLOCK_PASTE, Actions.ELEMENT_DELETE, Actions.SELECT_ALL],
- [Actions.BLOCK_ROTATE_CCW, Actions.BLOCK_ROTATE_CW, ('_Align', Actions.BLOCK_ALIGNMENTS)],
+ [Actions.BLOCK_CUT, Actions.BLOCK_COPY, Actions.BLOCK_PASTE,
+ Actions.ELEMENT_DELETE, Actions.SELECT_ALL],
+ [Actions.BLOCK_ROTATE_CCW, Actions.BLOCK_ROTATE_CW,
+ ('_Align', Actions.BLOCK_ALIGNMENTS)],
[Actions.BLOCK_ENABLE, Actions.BLOCK_DISABLE, Actions.BLOCK_BYPASS],
[Actions.BLOCK_PARAM_MODIFY]
]),
('_View', [
[Actions.TOGGLE_BLOCKS_WINDOW],
- [Actions.TOGGLE_CONSOLE_WINDOW, Actions.TOGGLE_SCROLL_LOCK, Actions.SAVE_CONSOLE, Actions.CLEAR_CONSOLE],
+ [Actions.TOGGLE_CONSOLE_WINDOW, Actions.TOGGLE_SCROLL_LOCK,
+ Actions.SAVE_CONSOLE, Actions.CLEAR_CONSOLE],
[Actions.TOGGLE_HIDE_VARIABLES, Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR, Actions.TOGGLE_FLOW_GRAPH_VAR_EDITOR_SIDEBAR,
Actions.TOGGLE_SHOW_PARAMETER_EXPRESSION, Actions.TOGGLE_SHOW_PARAMETER_EVALUATION],
- [Actions.TOGGLE_HIDE_DISABLED_BLOCKS, Actions.TOGGLE_AUTO_HIDE_PORT_LABELS, Actions.TOGGLE_SNAP_TO_GRID, Actions.TOGGLE_SHOW_BLOCK_COMMENTS, Actions.TOGGLE_SHOW_BLOCK_IDS,],
+ [Actions.TOGGLE_HIDE_DISABLED_BLOCKS, Actions.TOGGLE_AUTO_HIDE_PORT_LABELS,
+ Actions.TOGGLE_SNAP_TO_GRID, Actions.TOGGLE_SHOW_BLOCK_COMMENTS, Actions.TOGGLE_SHOW_BLOCK_IDS, ],
[Actions.TOGGLE_SHOW_CODE_PREVIEW_TAB],
[Actions.ZOOM_IN],
[Actions.ZOOM_OUT],
@@ -87,15 +95,18 @@ MENU_BAR_LIST = [
[Actions.TOGGLE_SHOW_FLOWGRAPH_COMPLEXITY]
]),
('_Help', [
- [Actions.HELP_WINDOW_DISPLAY, Actions.TYPES_WINDOW_DISPLAY, Actions.KEYBOARD_SHORTCUTS_WINDOW_DISPLAY, Actions.XML_PARSER_ERRORS_DISPLAY],
+ [Actions.HELP_WINDOW_DISPLAY, Actions.TYPES_WINDOW_DISPLAY,
+ Actions.KEYBOARD_SHORTCUTS_WINDOW_DISPLAY, Actions.XML_PARSER_ERRORS_DISPLAY],
[Actions.GET_INVOLVED_WINDOW_DISPLAY, Actions.ABOUT_WINDOW_DISPLAY]
])]
# The list of actions for the context menu.
CONTEXT_MENU_LIST = [
- [Actions.BLOCK_CUT, Actions.BLOCK_COPY, Actions.BLOCK_PASTE, Actions.ELEMENT_DELETE],
- [Actions.BLOCK_ROTATE_CCW, Actions.BLOCK_ROTATE_CW, Actions.BLOCK_ENABLE, Actions.BLOCK_DISABLE, Actions.BLOCK_BYPASS],
+ [Actions.BLOCK_CUT, Actions.BLOCK_COPY,
+ Actions.BLOCK_PASTE, Actions.ELEMENT_DELETE],
+ [Actions.BLOCK_ROTATE_CCW, Actions.BLOCK_ROTATE_CW,
+ Actions.BLOCK_ENABLE, Actions.BLOCK_DISABLE, Actions.BLOCK_BYPASS],
[("_More", [
[Actions.BLOCK_CREATE_HIER, Actions.OPEN_HIER],
[Actions.BUSSIFY_SOURCES, Actions.BUSSIFY_SINKS]
@@ -181,7 +192,8 @@ class MenuHelper(SubMenuHelper):
target = "{}.{}".format(parent.prefix, parent.name)
menuitem = Gio.MenuItem.new(label, None)
if hasattr(parent, "icon_name"):
- menuitem.set_icon(Gio.Icon.new_for_string(parent.icon_name))
+ menuitem.set_icon(
+ Gio.Icon.new_for_string(parent.icon_name))
# Create the new submenu
if isinstance(child, list):
@@ -216,6 +228,7 @@ class MenuHelper(SubMenuHelper):
parent_obj.remove(obj_idx)
parent_obj.insert_item(obj_idx, obj)
+
class ToolbarHelper(SubMenuHelper):
"""
Builds a toolbar from a given list of actions.
@@ -275,6 +288,7 @@ class ToolbarHelper(SubMenuHelper):
create_func, parent_obj, _, obj, set_func = self.submenus[name]
set_func(obj, create_func())
+
class Menu(Gio.Menu, MenuHelper):
""" Main Menu """
@@ -309,7 +323,7 @@ class Toolbar(Gtk.Toolbar, ToolbarHelper):
ToolbarHelper.__init__(self)
self.set_style(Gtk.ToolbarStyle.ICONS)
- #self.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
+ # self.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
- #SubMenuCreator.__init__(self)
+ # SubMenuCreator.__init__(self)
self.build_toolbar(TOOLBAR_LIST, self)
diff --git a/grc/gui/BlockTreeWindow.py b/grc/gui/BlockTreeWindow.py
index 2f359f8c43..05341ec52b 100644
--- a/grc/gui/BlockTreeWindow.py
+++ b/grc/gui/BlockTreeWindow.py
@@ -34,7 +34,8 @@ def _format_doc(doc):
def _format_cat_tooltip(category):
- tooltip = '{}: {}'.format('Category' if len(category) > 1 else 'Module', category[-1])
+ tooltip = '{}: {}'.format('Category' if len(
+ category) > 1 else 'Module', category[-1])
if category == ('Core',):
tooltip += '\n\nThis subtree is meant for blocks included with GNU Radio (in-tree).'
@@ -68,26 +69,33 @@ class BlockTreeWindow(Gtk.VBox):
# search entry
self.search_entry = Gtk.Entry()
try:
- self.search_entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, 'edit-find')
- self.search_entry.set_icon_activatable(Gtk.EntryIconPosition.PRIMARY, False)
- self.search_entry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, 'window-close')
+ self.search_entry.set_icon_from_icon_name(
+ Gtk.EntryIconPosition.PRIMARY, 'edit-find')
+ self.search_entry.set_icon_activatable(
+ Gtk.EntryIconPosition.PRIMARY, False)
+ self.search_entry.set_icon_from_icon_name(
+ Gtk.EntryIconPosition.SECONDARY, 'window-close')
self.search_entry.connect('icon-release', self._handle_icon_event)
except AttributeError:
pass # no icon for old pygtk
self.search_entry.connect('changed', self._update_search_tree)
- self.search_entry.connect('key-press-event', self._handle_search_key_press)
+ self.search_entry.connect(
+ 'key-press-event', self._handle_search_key_press)
self.pack_start(self.search_entry, False, False, 0)
# make the tree model for holding blocks and a temporary one for search results
- self.treestore = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
- self.treestore_search = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
+ self.treestore = Gtk.TreeStore(
+ GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
+ self.treestore_search = Gtk.TreeStore(
+ GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
self.treeview = Gtk.TreeView(model=self.treestore)
self.treeview.set_enable_search(False) # disable pop up search box
self.treeview.set_search_column(-1) # really disable search
self.treeview.set_headers_visible(False)
self.treeview.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
- self.treeview.connect('button-press-event', self._handle_mouse_button_press)
+ self.treeview.connect('button-press-event',
+ self._handle_mouse_button_press)
self.treeview.connect('key-press-event', self._handle_search_key_press)
self.treeview.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
@@ -99,13 +107,16 @@ class BlockTreeWindow(Gtk.VBox):
column.set_sort_column_id(0)
self.treestore.set_sort_column_id(0, Gtk.SortType.ASCENDING)
# setup drag and drop
- self.treeview.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, Constants.DND_TARGETS, Gdk.DragAction.COPY)
+ self.treeview.enable_model_drag_source(
+ Gdk.ModifierType.BUTTON1_MASK, Constants.DND_TARGETS, Gdk.DragAction.COPY)
self.treeview.connect('drag-data-get', self._handle_drag_get_data)
# make the scrolled window to hold the tree view
scrolled_window = Gtk.ScrolledWindow()
- scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ scrolled_window.set_policy(
+ Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolled_window.add(self.treeview)
- scrolled_window.set_size_request(Constants.DEFAULT_BLOCKS_WINDOW_WIDTH, -1)
+ scrolled_window.set_size_request(
+ Constants.DEFAULT_BLOCKS_WINDOW_WIDTH, -1)
self.pack_start(scrolled_window, True, True, 0)
# map categories to iters, automatic mapping for root
self._categories = {tuple(): None}
@@ -128,10 +139,11 @@ class BlockTreeWindow(Gtk.VBox):
self.treeview.collapse_all()
core_module_iter = self._categories.get((module_name,))
if core_module_iter:
- self.treeview.expand_row(self.treestore.get_path(core_module_iter), False)
+ self.treeview.expand_row(
+ self.treestore.get_path(core_module_iter), False)
############################################################
- ## Block Tree Methods
+ # Block Tree Methods
############################################################
def add_block(self, block, treestore=None, categories=None):
"""
@@ -144,16 +156,19 @@ class BlockTreeWindow(Gtk.VBox):
treestore = treestore or self.treestore
categories = categories or self._categories
- category = tuple(filter(str, block.category)) # tuple is hashable, remove empty cats
+ # tuple is hashable, remove empty cats
+ category = tuple(filter(str, block.category))
# add category and all sub categories
for level, parent_cat_name in enumerate(category, 1):
parent_category = category[:level]
if parent_category not in categories:
- iter_ = treestore.insert_before(categories[parent_category[:-1]], None)
+ iter_ = treestore.insert_before(
+ categories[parent_category[:-1]], None)
treestore.set_value(iter_, NAME_INDEX, parent_cat_name)
treestore.set_value(iter_, KEY_INDEX, '')
- treestore.set_value(iter_, DOC_INDEX, _format_cat_tooltip(parent_category))
+ treestore.set_value(
+ iter_, DOC_INDEX, _format_cat_tooltip(parent_category))
categories[parent_category] = iter_
# add block
iter_ = treestore.insert_before(categories[category], None)
@@ -175,7 +190,7 @@ class BlockTreeWindow(Gtk.VBox):
self.treestore_search.foreach(update_doc)
############################################################
- ## Helper Methods
+ # Helper Methods
############################################################
def _get_selected_block_key(self):
"""
@@ -195,7 +210,7 @@ class BlockTreeWindow(Gtk.VBox):
self.treeview.expand_to_path(path)
############################################################
- ## Event Handlers
+ # Event Handlers
############################################################
def _handle_icon_event(self, widget, icon, event):
if icon == Gtk.EntryIconPosition.PRIMARY:
@@ -216,7 +231,8 @@ class BlockTreeWindow(Gtk.VBox):
self.treestore_search.clear()
self._categories_search = {tuple(): None}
for block in matching_blocks:
- self.add_block(block, self.treestore_search, self._categories_search)
+ self.add_block(block, self.treestore_search,
+ self._categories_search)
self.treeview.set_model(self.treestore_search)
self.treeview.expand_all()
@@ -232,7 +248,8 @@ class BlockTreeWindow(Gtk.VBox):
selected = self.treestore_search.iter_children(selected)
if selected is not None:
key = self.treestore_search.get_value(selected, KEY_INDEX)
- if key: self.emit('create_new_block', key)
+ if key:
+ self.emit('create_new_block', key)
elif widget == self.treeview:
key = self._get_selected_block_key()
if key:
@@ -248,7 +265,7 @@ class BlockTreeWindow(Gtk.VBox):
self.search_entry.hide()
elif (event.get_state() & Gdk.ModifierType.CONTROL_MASK and event.keyval == Gdk.KEY_f) \
- or event.keyval == Gdk.KEY_slash:
+ or event.keyval == Gdk.KEY_slash:
# propagation doesn't work although treeview search is disabled =(
# manually trigger action...
Actions.FIND_BLOCKS.activate()
@@ -258,7 +275,7 @@ class BlockTreeWindow(Gtk.VBox):
Actions.TOGGLE_BLOCKS_WINDOW.activate()
else:
- return False # propagate event
+ return False # propagate event
return True
diff --git a/grc/gui/Config.py b/grc/gui/Config.py
index ee354ba54d..35d2eefcca 100644
--- a/grc/gui/Config.py
+++ b/grc/gui/Config.py
@@ -142,7 +142,8 @@ class Config(CoreConfig):
def get_recent_files(self):
""" Gets recent files, removes any that do not exist and re-saves it """
- files = list(filter(os.path.exists, self.get_file_list('files_recent')))
+ files = list(
+ filter(os.path.exists, self.get_file_list('files_recent')))
self.set_recent_files(files)
return files
@@ -168,9 +169,9 @@ class Config(CoreConfig):
# Figure out default
if sidebar:
_, h = self.main_window_size()
- return self.entry('variable_editor_sidebar_position', pos, default=int(h*0.7))
+ return self.entry('variable_editor_sidebar_position', pos, default=int(h * 0.7))
else:
- return self.entry('variable_editor_position', pos, default=int(self.blocks_window_position()*0.5))
+ return self.entry('variable_editor_position', pos, default=int(self.blocks_window_position() * 0.5))
def variable_editor_sidebar(self, pos=None):
return self.entry('variable_editor_sidebar', pos, default=False)
diff --git a/grc/gui/Console.py b/grc/gui/Console.py
index 40345b9699..f88191cd88 100644
--- a/grc/gui/Console.py
+++ b/grc/gui/Console.py
@@ -7,17 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later
"""
+from ..core import Messages
+from .Dialogs import TextDisplay, MessageDialogWrapper
+from .Constants import DEFAULT_CONSOLE_WINDOW_WIDTH
+from gi.repository import Gtk, Gdk, GObject
import os
import logging
import gi
gi.require_version('Gtk', '3.0')
-from gi.repository import Gtk, Gdk, GObject
-
-from .Constants import DEFAULT_CONSOLE_WINDOW_WIDTH
-from .Dialogs import TextDisplay, MessageDialogWrapper
-
-from ..core import Messages
log = logging.getLogger(__name__)
diff --git a/grc/gui/Constants.py b/grc/gui/Constants.py
index 2effc8c98c..dd74497468 100644
--- a/grc/gui/Constants.py
+++ b/grc/gui/Constants.py
@@ -91,7 +91,8 @@ and kindly ask to update their GRC Block Descriptions or Block Tree to include a
# _SCREEN = Gdk.Screen.get_default()
# _SCREEN_RESOLUTION = _SCREEN.get_resolution() if _SCREEN else -1
# DPI_SCALING = _SCREEN_RESOLUTION / 96.0 if _SCREEN_RESOLUTION > 0 else 1.0
-DPI_SCALING = 1.0 # todo: figure out the GTK3 way (maybe cairo does this for us
+# todo: figure out the GTK3 way (maybe cairo does this for us
+DPI_SCALING = 1.0
# Gtk-themes classified as dark
GTK_DARK_THEMES = [
@@ -113,7 +114,10 @@ def update_font_size(font_size):
PORT_FONT = BLOCK_FONT
PARAM_FONT = "%s %f" % (FONT_FAMILY, font_size - 0.5)
- PORT_SEPARATION = PORT_SPACING + 2 * PORT_LABEL_PADDING + int(1.5 * font_size)
- PORT_SEPARATION += -PORT_SEPARATION % (2 * CANVAS_GRID_SIZE) # even multiple
+ PORT_SEPARATION = PORT_SPACING + 2 * \
+ PORT_LABEL_PADDING + int(1.5 * font_size)
+ PORT_SEPARATION += - \
+ PORT_SEPARATION % (2 * CANVAS_GRID_SIZE) # even multiple
+
update_font_size(DEFAULT_FONT_SIZE)
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index a51b1c44e7..7bdfb2aecb 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -237,7 +237,8 @@ class ErrorsDialog(Gtk.Dialog):
aspect = "Connection to '{}'".format(element.sink_block.name)
elif element.is_port:
src = element.parent_block.name
- aspect = "{} '{}'".format('Sink' if element.is_sink else 'Source', element.name)
+ aspect = "{} '{}'".format(
+ 'Sink' if element.is_sink else 'Source', element.name)
elif element.is_param:
src = element.parent_block.name
aspect = "Param '{}'".format(element.name)
@@ -279,7 +280,7 @@ def show_about(parent, config):
except GLib.Error:
Messages.send("Failed to set window logo\n")
- #ad.set_comments("")
+ # ad.set_comments("")
ad.set_copyright(config.license.splitlines()[0])
ad.set_website(config.website)
@@ -311,6 +312,7 @@ def show_help(parent):
parent, Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, title='Help', markup=markup
).run_and_destroy()
+
def show_keyboard_shortcuts(parent):
""" Display keyboard shortcut-keys. """
markup = textwrap.dedent("""\
@@ -371,7 +373,8 @@ def show_get_involved(parent):
def show_types(parent):
""" Display information about standard data types. """
- colors = [(name, color) for name, key, sizeof, color in Constants.CORE_TYPES]
+ colors = [(name, color)
+ for name, key, sizeof, color in Constants.CORE_TYPES]
max_len = 10 + max(len(name) for name, code in colors)
message = '\n'.join(
@@ -424,7 +427,8 @@ def choose_editor(parent, config):
file_dialog = Gtk.FileChooserDialog(
'Select an Editor...', None,
Gtk.FileChooserAction.OPEN,
- ('gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-open', Gtk.ResponseType.OK),
+ ('gtk-cancel', Gtk.ResponseType.CANCEL,
+ 'gtk-open', Gtk.ResponseType.OK),
transient_for=parent
)
file_dialog.set_select_multiple(False)
@@ -449,7 +453,8 @@ def choose_editor(parent, config):
# Save
editor = config.editor = process
except Exception:
- Messages.send('>>> Unable to load the default editor. Please choose an editor.\n')
+ Messages.send(
+ '>>> Unable to load the default editor. Please choose an editor.\n')
if editor == '':
Messages.send('>>> No editor selected.\n')
diff --git a/grc/gui/DrawingArea.py b/grc/gui/DrawingArea.py
index 5295caedbb..d94a890272 100644
--- a/grc/gui/DrawingArea.py
+++ b/grc/gui/DrawingArea.py
@@ -79,10 +79,10 @@ class DrawingArea(Gtk.DrawingArea):
self.set_can_focus(True)
self.connect('focus-out-event', self._handle_focus_lost_event)
-
##########################################################################
# Handlers
##########################################################################
+
def _handle_drag_data_received(self, widget, drag_context, x, y, selection_data, info, time):
"""
Handle a drag and drop by adding a block at the given coordinate.
@@ -96,7 +96,7 @@ class DrawingArea(Gtk.DrawingArea):
self._set_zoom_factor(zoom_factor)
def zoom_out(self):
- change = 1/1.2
+ change = 1 / 1.2
zoom_factor = max(self.zoom_factor * change, 0.1)
self._set_zoom_factor(zoom_factor)
diff --git a/grc/gui/Executor.py b/grc/gui/Executor.py
index 4505ef0b37..78f91d93e2 100644
--- a/grc/gui/Executor.py
+++ b/grc/gui/Executor.py
@@ -80,7 +80,8 @@ class ExecFlowGraphThread(threading.Thread):
Execute this C++ flow graph after generating and compiling it.
"""
generator = self.page.get_generator()
- run_command = generator.file_path + '/build/' + self.flow_graph.get_option('id')
+ run_command = generator.file_path + \
+ '/build/' + self.flow_graph.get_option('id')
dirname = generator.file_path
builddir = os.path.join(dirname, 'build')
diff --git a/grc/gui/FileDialogs.py b/grc/gui/FileDialogs.py
index acb2ed8610..ceca919531 100644
--- a/grc/gui/FileDialogs.py
+++ b/grc/gui/FileDialogs.py
@@ -41,7 +41,8 @@ class FileDialogHelper(Gtk.FileChooserDialog, object):
Gtk.FileChooserDialog.__init__(self, title=self.title, action=self.action,
transient_for=parent)
- self.add_buttons('gtk-cancel', Gtk.ResponseType.CANCEL, ok_stock, Gtk.ResponseType.OK)
+ self.add_buttons('gtk-cancel', Gtk.ResponseType.CANCEL,
+ ok_stock, Gtk.ResponseType.OK)
self.set_select_multiple(False)
self.set_local_only(True)
@@ -49,12 +50,14 @@ class FileDialogHelper(Gtk.FileChooserDialog, object):
self.current_file_path = current_file_path or path.join(
Constants.DEFAULT_FILE_PATH, Constants.NEW_FLOGRAPH_TITLE + Constants.FILE_EXTENSION)
- self.set_current_folder(path.dirname(current_file_path)) # current directory
+ self.set_current_folder(path.dirname(
+ current_file_path)) # current directory
self.setup_filters()
def setup_filters(self, filters=None):
set_default = True
- filters = filters or ([(self.filter_label, self.filter_ext)] if self.filter_label else [])
+ filters = filters or (
+ [(self.filter_label, self.filter_ext)] if self.filter_label else [])
filters.append(('All Files', ''))
for label, ext in filters:
if not label:
@@ -81,7 +84,8 @@ class SaveFileDialog(FileDialogHelper):
def __init__(self, parent, current_file_path):
super(SaveFileDialog, self).__init__(parent, current_file_path)
- self.set_current_name(path.splitext(path.basename(self.current_file_path))[0] + self.filter_ext)
+ self.set_current_name(path.splitext(path.basename(
+ self.current_file_path))[0] + self.filter_ext)
self.set_create_folders(True)
self.set_do_overwrite_confirmation(True)
@@ -94,7 +98,8 @@ class OpenFileDialog(FileDialogHelper):
Dialogs.MessageDialogWrapper(
self.parent,
Gtk.MessageType.WARNING, Gtk.ButtonsType.CLOSE, 'Cannot Open!',
- 'File <b>{filename}</b> Does not Exist!'.format(filename=Utils.encode(filename)),
+ 'File <b>{filename}</b> Does not Exist!'.format(
+ filename=Utils.encode(filename)),
).run_and_destroy()
def get_filename(self):
@@ -145,7 +150,8 @@ class SaveConsole(SaveFileDialog):
class SaveScreenShot(SaveFileDialog):
title = 'Save a Flow Graph Screen Shot...'
- filters = [('PDF Files', '.pdf'), ('PNG Files', '.png'), ('SVG Files', '.svg')]
+ filters = [('PDF Files', '.pdf'), ('PNG Files', '.png'),
+ ('SVG Files', '.svg')]
filter_ext = '.pdf' # the default
def __init__(self, parent, current_file_path=''):
@@ -154,7 +160,8 @@ class SaveScreenShot(SaveFileDialog):
self.config = Gtk.Application.get_default().config
self._button = button = Gtk.CheckButton(label='Background transparent')
- self._button.set_active(self.config.screen_shot_background_transparent())
+ self._button.set_active(
+ self.config.screen_shot_background_transparent())
self.set_extra_widget(button)
def setup_filters(self, filters=None):
@@ -164,7 +171,8 @@ class SaveScreenShot(SaveFileDialog):
Dialogs.MessageDialogWrapper(
self.parent,
Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, 'Can not Save!',
- 'File Extension of <b>{filename}</b> not supported!'.format(filename=Utils.encode(filename)),
+ 'File Extension of <b>{filename}</b> not supported!'.format(
+ filename=Utils.encode(filename)),
).run_and_destroy()
def run(self):
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index 7e8462b3ef..5561c26419 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -43,7 +43,8 @@ class MainWindow(Gtk.ApplicationWindow):
MainWindow constructor
Setup the menu, toolbar, flow graph editor notebook, block selection window...
"""
- Gtk.ApplicationWindow.__init__(self, title="GNU Radio Companion", application=app)
+ Gtk.ApplicationWindow.__init__(
+ self, title="GNU Radio Companion", application=app)
log.debug("__init__()")
self._platform = platform
@@ -63,7 +64,8 @@ class MainWindow(Gtk.ApplicationWindow):
icon = icon_theme.lookup_icon("gnuradio-grc", 48, 0)
if not icon:
# Set default window icon
- self.set_icon_from_file(os.path.dirname(os.path.abspath(__file__)) + "/icon.png")
+ self.set_icon_from_file(os.path.dirname(
+ os.path.abspath(__file__)) + "/icon.png")
else:
# Use gnuradio icon
self.set_icon(icon.load_icon())
@@ -85,7 +87,7 @@ class MainWindow(Gtk.ApplicationWindow):
vbox.pack_start(self.tool_bar, False, False, 0)
# Main parent container for the different panels
- self.main = Gtk.HPaned() #(orientation=Gtk.Orientation.HORIZONTAL)
+ self.main = Gtk.HPaned() # (orientation=Gtk.Orientation.HORIZONTAL)
vbox.pack_start(self.main, True, True, 0)
# Create the notebook
@@ -99,15 +101,19 @@ class MainWindow(Gtk.ApplicationWindow):
# Create the block tree and variable panels
self.btwin = BlockTreeWindow(platform)
- self.btwin.connect('create_new_block', self._add_block_to_current_flow_graph)
+ self.btwin.connect('create_new_block',
+ self._add_block_to_current_flow_graph)
self.vars = VariableEditor()
- self.vars.connect('create_new_block', self._add_block_to_current_flow_graph)
- self.vars.connect('remove_block', self._remove_block_from_current_flow_graph)
+ self.vars.connect('create_new_block',
+ self._add_block_to_current_flow_graph)
+ self.vars.connect(
+ 'remove_block', self._remove_block_from_current_flow_graph)
# Figure out which place to put the variable editor
- self.left = Gtk.VPaned() #orientation=Gtk.Orientation.VERTICAL)
- self.right = Gtk.VPaned() #orientation=Gtk.Orientation.VERTICAL)
- self.left_subpanel = Gtk.HPaned() #orientation=Gtk.Orientation.HORIZONTAL)
+ self.left = Gtk.VPaned() # orientation=Gtk.Orientation.VERTICAL)
+ self.right = Gtk.VPaned() # orientation=Gtk.Orientation.VERTICAL)
+ # orientation=Gtk.Orientation.HORIZONTAL)
+ self.left_subpanel = Gtk.HPaned()
self.variable_panel_sidebar = self.config.variable_editor_sidebar()
if self.variable_panel_sidebar:
@@ -133,9 +139,11 @@ class MainWindow(Gtk.ApplicationWindow):
self.main.set_position(self.config.blocks_window_position())
self.left.set_position(self.config.console_window_position())
if self.variable_panel_sidebar:
- self.right.set_position(self.config.variable_editor_position(sidebar=True))
+ self.right.set_position(
+ self.config.variable_editor_position(sidebar=True))
else:
- self.left_subpanel.set_position(self.config.variable_editor_position())
+ self.left_subpanel.set_position(
+ self.config.variable_editor_position())
self.show_all()
log.debug("Main window ready")
@@ -238,16 +246,18 @@ class MainWindow(Gtk.ApplicationWindow):
file_path: optional file to load into the flow graph
show: true if the page should be shown after loading
"""
- #if the file is already open, show the open page and return
- if file_path and file_path in self._get_files(): #already open
- page = self.notebook.get_nth_page(self._get_files().index(file_path))
+ # if the file is already open, show the open page and return
+ if file_path and file_path in self._get_files(): # already open
+ page = self.notebook.get_nth_page(
+ self._get_files().index(file_path))
self._set_page(page)
return
- try: #try to load from file
- if file_path: Messages.send_start_load(file_path)
+ try: # try to load from file
+ if file_path:
+ Messages.send_start_load(file_path)
flow_graph = self._platform.make_flow_graph()
flow_graph.grc_file_path = file_path
- #print flow_graph
+ # print flow_graph
page = Page(
self,
flow_graph=flow_graph,
@@ -260,18 +270,20 @@ class MainWindow(Gtk.ApplicationWindow):
str(Messages.flowgraph_error)
)
)
- if file_path: Messages.send_end_load()
- except Exception as e: #return on failure
+ if file_path:
+ Messages.send_end_load()
+ except Exception as e: # return on failure
Messages.send_fail_load(e)
if isinstance(e, KeyError) and str(e) == "'options'":
# This error is unrecoverable, so crash gracefully
exit(-1)
return
- #add this page to the notebook
+ # add this page to the notebook
self.notebook.append_page(page, page.tab)
self.notebook.set_tab_reorderable(page, True)
- #only show if blank or manual
- if not file_path or show: self._set_page(page)
+ # only show if blank or manual
+ if not file_path or show:
+ self._set_page(page)
def close_pages(self):
"""
@@ -280,25 +292,29 @@ class MainWindow(Gtk.ApplicationWindow):
Returns:
true if all closed
"""
- open_files = [file for file in self._get_files() if file] #filter blank files
+ open_files = [file for file in self._get_files()
+ if file] # filter blank files
open_file = self.current_page.file_path
- #close each page
+ # close each page
for page in sorted(self.get_pages(), key=lambda p: p.saved):
self.page_to_be_closed = page
closed = self.close_page(False)
if not closed:
break
- if self.notebook.get_n_pages(): return False
- #save state before closing
+ if self.notebook.get_n_pages():
+ return False
+ # save state before closing
self.config.set_open_files(open_files)
self.config.file_open(open_file)
self.config.main_window_size(self.get_size())
self.config.console_window_position(self.left.get_position())
self.config.blocks_window_position(self.main.get_position())
if self.variable_panel_sidebar:
- self.config.variable_editor_position(self.right.get_position(), sidebar=True)
+ self.config.variable_editor_position(
+ self.right.get_position(), sidebar=True)
else:
- self.config.variable_editor_position(self.left_subpanel.get_position())
+ self.config.variable_editor_position(
+ self.left_subpanel.get_position())
self.config.save()
return True
@@ -311,29 +327,31 @@ class MainWindow(Gtk.ApplicationWindow):
Args:
ensure: boolean
"""
- if not self.page_to_be_closed: self.page_to_be_closed = self.current_page
- #show the page if it has an executing flow graph or is unsaved
+ if not self.page_to_be_closed:
+ self.page_to_be_closed = self.current_page
+ # show the page if it has an executing flow graph or is unsaved
if self.page_to_be_closed.process or not self.page_to_be_closed.saved:
self._set_page(self.page_to_be_closed)
- #unsaved? ask the user
+ # unsaved? ask the user
if not self.page_to_be_closed.saved:
- response = self._save_changes() # return value is either OK, CLOSE, or CANCEL
+ response = self._save_changes() # return value is either OK, CLOSE, or CANCEL
if response == Gtk.ResponseType.OK:
- Actions.FLOW_GRAPH_SAVE() #try to save
- if not self.page_to_be_closed.saved: #still unsaved?
- self.page_to_be_closed = None #set the page to be closed back to None
+ Actions.FLOW_GRAPH_SAVE() # try to save
+ if not self.page_to_be_closed.saved: # still unsaved?
+ self.page_to_be_closed = None # set the page to be closed back to None
return False
elif response == Gtk.ResponseType.CANCEL:
self.page_to_be_closed = None
return False
- #stop the flow graph if executing
+ # stop the flow graph if executing
if self.page_to_be_closed.process:
Actions.FLOW_GRAPH_KILL()
- #remove the page
- self.notebook.remove_page(self.notebook.page_num(self.page_to_be_closed))
+ # remove the page
+ self.notebook.remove_page(
+ self.notebook.page_num(self.page_to_be_closed))
if ensure and self.notebook.get_n_pages() == 0:
- self.new_page() #no pages, make a new one
- self.page_to_be_closed = None #set the page to be closed back to None
+ self.new_page() # no pages, make a new one
+ self.page_to_be_closed = None # set the page to be closed back to None
return True
############################################################
@@ -405,7 +423,8 @@ class MainWindow(Gtk.ApplicationWindow):
page: the page widget
"""
self.current_page = page
- self.notebook.set_current_page(self.notebook.page_num(self.current_page))
+ self.notebook.set_current_page(
+ self.notebook.page_num(self.current_page))
def _save_changes(self):
"""
diff --git a/grc/gui/Notebook.py b/grc/gui/Notebook.py
index 02f27dc316..457e115d3f 100644
--- a/grc/gui/Notebook.py
+++ b/grc/gui/Notebook.py
@@ -118,9 +118,12 @@ class Page(Gtk.HBox):
self.viewport.add(self.drawing_area)
self.scrolled_window = Gtk.ScrolledWindow()
- self.scrolled_window.set_size_request(MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT)
- self.scrolled_window.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
- self.scrolled_window.connect('key-press-event', self._handle_scroll_window_key_press)
+ self.scrolled_window.set_size_request(
+ MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT)
+ self.scrolled_window.set_policy(
+ Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
+ self.scrolled_window.connect(
+ 'key-press-event', self._handle_scroll_window_key_press)
self.scrolled_window.add(self.viewport)
self.pack_start(self.scrolled_window, True, True, 0)
diff --git a/grc/gui/ParamWidgets.py b/grc/gui/ParamWidgets.py
index 1cdfc34989..acb95b106f 100644
--- a/grc/gui/ParamWidgets.py
+++ b/grc/gui/ParamWidgets.py
@@ -42,6 +42,7 @@ def have_dark_theme():
return False
return is_dark_theme(theme)
+
def add_style_provider():
"""
Load GTK styles
@@ -55,6 +56,8 @@ def add_style_provider():
style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
+
+
add_style_provider()
@@ -93,7 +96,8 @@ class InputParam(Gtk.HBox):
"""
Set the markup, color, tooltip, show/hide.
"""
- self.label.set_markup(self.param.format_label_markup(self._have_pending_changes))
+ self.label.set_markup(
+ self.param.format_label_markup(self._have_pending_changes))
self.set_color('dtype_' + self.param.dtype)
self.set_tooltip_text(self.param.format_tooltip_text())
@@ -117,14 +121,14 @@ class InputParam(Gtk.HBox):
Handle a gui change by setting the new param value,
calling the callback (if applicable), and updating.
"""
- #set the new value
+ # set the new value
self.param.set_value(self.get_text())
- #call the callback
+ # call the callback
if self._changed_callback:
self._changed_callback(self, None)
else:
self.param.validate()
- #gui update
+ # gui update
self._have_pending_changes = False
self._update_gui()
@@ -205,7 +209,8 @@ class PythonEditorParam(InputParam):
self.pack_start(button, True, True, True)
def open_editor(self, widget=None):
- self.param.parent_flowgraph.install_external_editor(self.param, parent=self._transient_for)
+ self.param.parent_flowgraph.install_external_editor(
+ self.param, parent=self._transient_for)
def get_text(self):
pass # we never update the value from here
@@ -297,13 +302,15 @@ class FileParam(EntryParam):
"""
# get the paths
file_path = self.param.is_valid() and self.param.get_evaluated() or ''
- (dirname, basename) = os.path.isfile(file_path) and os.path.split(file_path) or (file_path, '')
+ (dirname, basename) = os.path.isfile(
+ file_path) and os.path.split(file_path) or (file_path, '')
# check for qss theme default directory
if self.param.key == 'qt_qss_theme':
dirname = os.path.dirname(dirname) # trim filename
if not os.path.exists(dirname):
- config = self.param.parent_platform.config
- dirname = os.path.join(config.install_prefix, '/share/gnuradio/themes')
+ config = self.param.parent_platform.config
+ dirname = os.path.join(
+ config.install_prefix, '/share/gnuradio/themes')
if not os.path.exists(dirname):
dirname = os.getcwd() # fix bad paths
@@ -313,17 +320,20 @@ class FileParam(EntryParam):
title='Open a Data File...', action=Gtk.FileChooserAction.OPEN,
transient_for=self._transient_for,
)
- file_dialog.add_buttons('gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-open', Gtk.ResponseType.OK)
+ file_dialog.add_buttons(
+ 'gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-open', Gtk.ResponseType.OK)
elif self.param.dtype == 'file_save':
file_dialog = Gtk.FileChooserDialog(
title='Save a Data File...', action=Gtk.FileChooserAction.SAVE,
transient_for=self._transient_for,
)
- file_dialog.add_buttons('gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-save', Gtk.ResponseType.OK)
+ file_dialog.add_buttons(
+ 'gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-save', Gtk.ResponseType.OK)
file_dialog.set_do_overwrite_confirmation(True)
file_dialog.set_current_name(basename) # show the current filename
else:
- raise ValueError("Can't open file chooser dialog for type " + repr(self.param.dtype))
+ raise ValueError(
+ "Can't open file chooser dialog for type " + repr(self.param.dtype))
file_dialog.set_current_folder(dirname) # current directory
file_dialog.set_select_multiple(False)
file_dialog.set_local_only(True)
@@ -334,6 +344,7 @@ class FileParam(EntryParam):
self._apply_change()
file_dialog.destroy() # destroy the dialog
+
class DirectoryParam(FileParam):
"""Provide an entry box for a directory and a button to browse for it."""
@@ -344,23 +355,26 @@ class DirectoryParam(FileParam):
"""
dirname = self.param.get_evaluated() if self.param.is_valid() else ''
- if not os.path.isdir(dirname): # Check if directory exists, if not fall back to workdir
+ # Check if directory exists, if not fall back to workdir
+ if not os.path.isdir(dirname):
dirname = os.getcwd()
- if self.param.dtype == "dir_select": # Setup directory selection dialog, and fail for unexpected dtype
+ if self.param.dtype == "dir_select": # Setup directory selection dialog, and fail for unexpected dtype
dir_dialog = Gtk.FileChooserDialog(
title='Select a Directory...', action=Gtk.FileChooserAction.SELECT_FOLDER,
transient_for=self._transient_for
)
else:
- raise ValueError("Can't open directory chooser dialog for type " + repr(self.param.dtype))
+ raise ValueError(
+ "Can't open directory chooser dialog for type " + repr(self.param.dtype))
# Set dialog properties
- dir_dialog.add_buttons('gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-open', Gtk.ResponseType.OK)
+ dir_dialog.add_buttons(
+ 'gtk-cancel', Gtk.ResponseType.CANCEL, 'gtk-open', Gtk.ResponseType.OK)
dir_dialog.set_current_folder(dirname)
dir_dialog.set_local_only(True)
dir_dialog.set_select_multiple(False)
-
+
# Show dialog and update parameter on success
if Gtk.ResponseType.OK == dir_dialog.run():
path = dir_dialog.get_filename()
diff --git a/grc/gui/ParserErrorsDialog.py b/grc/gui/ParserErrorsDialog.py
index 12f6f4c7a7..745dc47f0a 100644
--- a/grc/gui/ParserErrorsDialog.py
+++ b/grc/gui/ParserErrorsDialog.py
@@ -24,7 +24,8 @@ class ParserErrorsDialog(Gtk.Dialog):
Args:
block: a block instance
"""
- GObject.GObject.__init__(self, title='Parser Errors', buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT))
+ GObject.GObject.__init__(self, title='Parser Errors', buttons=(
+ Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT))
self._error_logs = None
self.tree_store = Gtk.TreeStore(str)
@@ -48,11 +49,12 @@ class ParserErrorsDialog(Gtk.Dialog):
tree_view.expand_row(row.path, False)
scrolled_window = Gtk.ScrolledWindow()
- scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ scrolled_window.set_policy(
+ Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolled_window.add(tree_view)
self.vbox.pack_start(scrolled_window, True)
- self.set_size_request(2*MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)
+ self.set_size_request(2 * MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)
self.show_all()
def update_tree_store(self, error_logs):
@@ -68,7 +70,8 @@ class ParserErrorsDialog(Gtk.Dialog):
code = None
for error in errors:
# http://lxml.de/api/lxml.etree._LogEntry-class.html
- em = self.tree_store.append(parent, ["Line {e.line}: {e.message}".format(e=error)])
+ em = self.tree_store.append(
+ parent, ["Line {e.line}: {e.message}".format(e=error)])
if code:
self.tree_store.append(em, ["\n".join(
"{} {}{}".format(line, code[line - 1].replace("\t", " ").strip("\n"),
diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py
index e7dd72edcf..570e6a4576 100644
--- a/grc/gui/PropsDialog.py
+++ b/grc/gui/PropsDialog.py
@@ -64,7 +64,8 @@ class PropsDialog(Gtk.Dialog):
self._docs_text_display = doc_view = SimpleTextDisplay()
doc_view.get_buffer().create_tag('b', weight=Pango.Weight.BOLD)
self._docs_box = Gtk.ScrolledWindow()
- self._docs_box.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ self._docs_box.set_policy(
+ Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self._docs_vbox = Gtk.VBox(homogeneous=False, spacing=0)
self._docs_box.add(self._docs_vbox)
self._docs_link = Gtk.Label(use_markup=True)
@@ -81,7 +82,8 @@ class PropsDialog(Gtk.Dialog):
# todo: set font size in non-deprecated way
# code_view.override_font(Pango.FontDescription('monospace %d' % Constants.FONT_SIZE))
code_box = Gtk.ScrolledWindow()
- code_box.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ code_box.set_policy(Gtk.PolicyType.AUTOMATIC,
+ Gtk.PolicyType.AUTOMATIC)
code_box.add(self._code_text_display)
notebook.append_page(code_box, Gtk.Label(label="Generated Code"))
else:
@@ -90,7 +92,8 @@ class PropsDialog(Gtk.Dialog):
# Error Messages for the block
self._error_messages_text_display = SimpleTextDisplay()
self._error_box = Gtk.ScrolledWindow()
- self._error_box.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ self._error_box.set_policy(
+ Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self._error_box.add(self._error_messages_text_display)
vpaned.pack2(self._error_box)
vpaned.set_position(int(0.65 * Constants.MIN_DIALOG_HEIGHT))
@@ -117,7 +120,8 @@ class PropsDialog(Gtk.Dialog):
label = Gtk.Label()
vbox = Gtk.VBox()
scroll_box = Gtk.ScrolledWindow()
- scroll_box.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ scroll_box.set_policy(Gtk.PolicyType.AUTOMATIC,
+ Gtk.PolicyType.AUTOMATIC)
scroll_box.add(vbox)
self.notebook.append_page(scroll_box, label)
self._params_boxes.append((category, label, vbox))
@@ -232,7 +236,8 @@ class PropsDialog(Gtk.Dialog):
buf.insert(pos, '\n')
# if given the current parameters an exact match can be made
- block_constructor = self._block.templates.render('make').rsplit('.', 2)[-1]
+ block_constructor = self._block.templates.render(
+ 'make').rsplit('.', 2)[-1]
block_class = block_constructor.partition('(')[0].strip()
if block_class in docstrings:
docstrings = {block_class: docstrings[block_class]}
diff --git a/grc/gui/StateCache.py b/grc/gui/StateCache.py
index b3eb4e9232..fff261a29e 100644
--- a/grc/gui/StateCache.py
+++ b/grc/gui/StateCache.py
@@ -9,6 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
from . import Actions
from .Constants import STATE_CACHE_SIZE
+
class StateCache(object):
"""
The state cache is an interface to a list to record data/states and to revert to previous states.
@@ -23,7 +24,7 @@ class StateCache(object):
Args:
initial_state: the initial state (nested data)
"""
- self.states = [None] * STATE_CACHE_SIZE #fill states
+ self.states = [None] * STATE_CACHE_SIZE # fill states
self.current_state_index = 0
self.num_prev_states = 0
self.num_next_states = 0
@@ -38,10 +39,12 @@ class StateCache(object):
Args:
state: the new state
"""
- self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE
+ self.current_state_index = (
+ self.current_state_index + 1) % STATE_CACHE_SIZE
self.states[self.current_state_index] = state
self.num_prev_states = self.num_prev_states + 1
- if self.num_prev_states == STATE_CACHE_SIZE: self.num_prev_states = STATE_CACHE_SIZE - 1
+ if self.num_prev_states == STATE_CACHE_SIZE:
+ self.num_prev_states = STATE_CACHE_SIZE - 1
self.num_next_states = 0
self.update_actions()
@@ -63,7 +66,8 @@ class StateCache(object):
the previous state or None
"""
if self.num_prev_states > 0:
- self.current_state_index = (self.current_state_index + STATE_CACHE_SIZE -1)%STATE_CACHE_SIZE
+ self.current_state_index = (
+ self.current_state_index + STATE_CACHE_SIZE - 1) % STATE_CACHE_SIZE
self.num_next_states = self.num_next_states + 1
self.num_prev_states = self.num_prev_states - 1
return self.get_current_state()
@@ -77,7 +81,8 @@ class StateCache(object):
the next state or None
"""
if self.num_next_states > 0:
- self.current_state_index = (self.current_state_index + 1)%STATE_CACHE_SIZE
+ self.current_state_index = (
+ self.current_state_index + 1) % STATE_CACHE_SIZE
self.num_next_states = self.num_next_states - 1
self.num_prev_states = self.num_prev_states + 1
return self.get_current_state()
diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py
index 165537c383..5c643c9596 100644
--- a/grc/gui/Utils.py
+++ b/grc/gui/Utils.py
@@ -32,7 +32,7 @@ def get_rotated_coordinate(coor, rotation):
# handles negative angles
rotation = (rotation + 360) % 360
if rotation not in Constants.POSSIBLE_ROTATIONS:
- raise ValueError('unusable rotation angle "%s"'%str(rotation))
+ raise ValueError('unusable rotation angle "%s"' % str(rotation))
# determine the number of degrees to rotate
cos_r, sin_r = {
0: (1, 0), 90: (0, 1), 180: (-1, 0), 270: (0, -1),
@@ -76,7 +76,7 @@ def num_to_str(num):
"""Convert a number to a string in engineering notation. E.g., 5e-9 -> 5n"""
template = '{:' + fmt + '}{}'
magnitude = abs(value)
- for exp, symbol in zip(range(9, -15-1, -3), 'GMk munpf'):
+ for exp, symbol in zip(range(9, -15 - 1, -3), 'GMk munpf'):
factor = 10 ** exp
if magnitude >= factor:
return template.format(value / factor, symbol.strip())
@@ -87,7 +87,8 @@ def num_to_str(num):
if num == 0:
return '0'
output = eng_notation(num.real) if num.real else ''
- output += eng_notation(num.imag, '+g' if output else 'g') + 'j' if num.imag else ''
+ output += eng_notation(num.imag, '+g' if output else 'g') + \
+ 'j' if num.imag else ''
return output
else:
return str(num)
@@ -144,6 +145,7 @@ def scale_scalar(coor, reverse=False):
factor = Constants.DPI_SCALING if not reverse else 1 / Constants.DPI_SCALING
return int(coor * factor)
+
def get_modifier_key(angle_brackets=False):
"""
Get the modifier key based on platform.
@@ -167,9 +169,11 @@ def get_modifier_key(angle_brackets=False):
_nproc = None
+
+
def get_cmake_nproc():
""" Get number of cmake processes for C++ flowgraphs """
- global _nproc # Cached result
+ global _nproc # Cached result
if _nproc:
return _nproc
try:
@@ -180,5 +184,5 @@ def get_cmake_nproc():
if not _nproc:
_nproc = 1
- _nproc = max(_nproc//2 - 1, 1)
+ _nproc = max(_nproc // 2 - 1, 1)
return _nproc
diff --git a/grc/gui/VariableEditor.py b/grc/gui/VariableEditor.py
index c5090ba899..4cda5b2c6d 100644
--- a/grc/gui/VariableEditor.py
+++ b/grc/gui/VariableEditor.py
@@ -22,29 +22,35 @@ class VariableEditorContextMenu(Gtk.Menu):
Gtk.Menu.__init__(self)
self.imports = Gtk.MenuItem(label="Add _Import")
- self.imports.connect('activate', var_edit.handle_action, var_edit.ADD_IMPORT)
+ self.imports.connect(
+ 'activate', var_edit.handle_action, var_edit.ADD_IMPORT)
self.add(self.imports)
self.variables = Gtk.MenuItem(label="Add _Variable")
- self.variables.connect('activate', var_edit.handle_action, var_edit.ADD_VARIABLE)
+ self.variables.connect(
+ 'activate', var_edit.handle_action, var_edit.ADD_VARIABLE)
self.add(self.variables)
self.add(Gtk.SeparatorMenuItem())
self.enable = Gtk.MenuItem(label="_Enable")
- self.enable.connect('activate', var_edit.handle_action, var_edit.ENABLE_BLOCK)
+ self.enable.connect(
+ 'activate', var_edit.handle_action, var_edit.ENABLE_BLOCK)
self.disable = Gtk.MenuItem(label="_Disable")
- self.disable.connect('activate', var_edit.handle_action, var_edit.DISABLE_BLOCK)
+ self.disable.connect(
+ 'activate', var_edit.handle_action, var_edit.DISABLE_BLOCK)
self.add(self.enable)
self.add(self.disable)
self.add(Gtk.SeparatorMenuItem())
self.delete = Gtk.MenuItem(label="_Delete")
- self.delete.connect('activate', var_edit.handle_action, var_edit.DELETE_BLOCK)
+ self.delete.connect(
+ 'activate', var_edit.handle_action, var_edit.DELETE_BLOCK)
self.add(self.delete)
self.add(Gtk.SeparatorMenuItem())
self.properties = Gtk.MenuItem(label="_Properties...")
- self.properties.connect('activate', var_edit.handle_action, var_edit.OPEN_PROPERTIES)
+ self.properties.connect(
+ 'activate', var_edit.handle_action, var_edit.OPEN_PROPERTIES)
self.add(self.properties)
self.show_all()
@@ -87,13 +93,16 @@ class VariableEditor(Gtk.VBox):
self.treeview = Gtk.TreeView(model=self.treestore)
self.treeview.set_enable_search(False)
self.treeview.set_search_column(-1)
- #self.treeview.set_enable_search(True)
- #self.treeview.set_search_column(ID_INDEX)
+ # self.treeview.set_enable_search(True)
+ # self.treeview.set_search_column(ID_INDEX)
self.treeview.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
self.treeview.set_headers_visible(True)
- self.treeview.connect('button-press-event', self._handle_mouse_button_press)
- self.treeview.connect('button-release-event', self._handle_mouse_button_release)
- self.treeview.connect('motion-notify-event', self._handle_motion_notify)
+ self.treeview.connect('button-press-event',
+ self._handle_mouse_button_press)
+ self.treeview.connect('button-release-event',
+ self._handle_mouse_button_release)
+ self.treeview.connect('motion-notify-event',
+ self._handle_motion_notify)
self.treeview.connect('key-press-event', self._handle_key_button_press)
# Block Name or Category
@@ -133,9 +142,11 @@ class VariableEditor(Gtk.VBox):
# Make the scrolled window to hold the tree view
scrolled_window = Gtk.ScrolledWindow()
- scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ scrolled_window.set_policy(
+ Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
scrolled_window.add(self.treeview)
- scrolled_window.set_size_request(Constants.DEFAULT_BLOCKS_WINDOW_WIDTH, -1)
+ scrolled_window.set_size_request(
+ Constants.DEFAULT_BLOCKS_WINDOW_WIDTH, -1)
self.pack_start(scrolled_window, True, True, 0)
# Context menus
@@ -215,9 +226,11 @@ class VariableEditor(Gtk.VBox):
imports = self.treestore.append(None, [None, 'Imports'])
variables = self.treestore.append(None, [None, 'Variables'])
for block in self._imports:
- self.treestore.append(imports, [block, block.params['id'].get_value()])
+ self.treestore.append(
+ imports, [block, block.params['id'].get_value()])
for block in sorted(self._variables, key=lambda v: v.name):
- self.treestore.append(variables, [block, block.params['id'].get_value()])
+ self.treestore.append(
+ variables, [block, block.params['id'].get_value()])
def _handle_name_edited_cb(self, cell, path, new_text):
block = self.treestore[path][BLOCK_INDEX]
@@ -243,7 +256,7 @@ class VariableEditor(Gtk.VBox):
self.emit('create_new_block', 'variable')
elif key == self.OPEN_PROPERTIES:
# TODO: This probably isn't working because the action doesn't expect a parameter
- #Actions.BLOCK_PARAM_MODIFY()
+ # Actions.BLOCK_PARAM_MODIFY()
pass
elif key == self.DELETE_BLOCK:
self.emit('remove_block', self._block.name)
@@ -251,12 +264,15 @@ class VariableEditor(Gtk.VBox):
if self._confirm_delete:
# Create a context menu to confirm the delete operation
confirmation_menu = Gtk.Menu()
- block_id = self._block.params['id'].get_value().replace("_", "__")
+ block_id = self._block.params['id'].get_value().replace(
+ "_", "__")
confirm = Gtk.MenuItem(label="Delete {}".format(block_id))
- confirm.connect('activate', self.handle_action, self.DELETE_BLOCK)
+ confirm.connect('activate', self.handle_action,
+ self.DELETE_BLOCK)
confirmation_menu.add(confirm)
confirmation_menu.show_all()
- confirmation_menu.popup(None, None, None, None, event.button, event.time)
+ confirmation_menu.popup(
+ None, None, None, None, event.button, event.time)
else:
self.handle_action(None, self.DELETE_BLOCK, None)
elif key == self.ENABLE_BLOCK:
@@ -287,7 +303,8 @@ class VariableEditor(Gtk.VBox):
if self._block and event.type == Gdk.EventType._2BUTTON_PRESS:
# Open the advanced dialog if it is a gui variable
if self._block.key not in ("variable", "import"):
- self.handle_action(None, self.OPEN_PROPERTIES, event=event)
+ self.handle_action(
+ None, self.OPEN_PROPERTIES, event=event)
return True
if event.type == Gdk.EventType.BUTTON_PRESS:
# User is adding/removing blocks
@@ -295,19 +312,24 @@ class VariableEditor(Gtk.VBox):
if path[2] > col.cell_get_position(self.action_cell)[0]:
if row[1] == "Imports":
# Add a new import block.
- self.handle_action(None, self.ADD_IMPORT, event=event)
+ self.handle_action(
+ None, self.ADD_IMPORT, event=event)
elif row[1] == "Variables":
# Add a new variable block
- self.handle_action(None, self.ADD_VARIABLE, event=event)
+ self.handle_action(
+ None, self.ADD_VARIABLE, event=event)
else:
- self.handle_action(None, self.DELETE_CONFIRM, event=event)
+ self.handle_action(
+ None, self.DELETE_CONFIRM, event=event)
return True
elif event.button == 3 and event.type == Gdk.EventType.BUTTON_PRESS:
if self._block:
- self._context_menu.update_sensitive(True, enabled=self._block.enabled)
+ self._context_menu.update_sensitive(
+ True, enabled=self._block.enabled)
else:
self._context_menu.update_sensitive(False)
- self._context_menu.popup(None, None, None, None, event.button, event.time)
+ self._context_menu.popup(
+ None, None, None, None, event.button, event.time)
# Null handler. Stops the treeview from handling double click events.
if event.type == Gdk.EventType._2BUTTON_PRESS:
diff --git a/grc/gui/__init__.py b/grc/gui/__init__.py
index 8b13789179..e69de29bb2 100644
--- a/grc/gui/__init__.py
+++ b/grc/gui/__init__.py
@@ -1 +0,0 @@
-
diff --git a/grc/gui/canvas/block.py b/grc/gui/canvas/block.py
index a2964bd7e7..c80e2b8771 100644
--- a/grc/gui/canvas/block.py
+++ b/grc/gui/canvas/block.py
@@ -64,7 +64,8 @@ class Block(CoreBlock, Drawable):
"""
coor = Utils.scale(coor, reverse=True)
if Actions.TOGGLE_SNAP_TO_GRID.get_active():
- offset_x, offset_y = (0, self.height / 2) if self.is_horizontal() else (self.height / 2, 0)
+ offset_x, offset_y = (
+ 0, self.height / 2) if self.is_horizontal() else (self.height / 2, 0)
coor = (
Utils.align_to_grid(coor[0] + offset_x) - offset_x,
Utils.align_to_grid(coor[1] + offset_y) - offset_y
@@ -137,8 +138,10 @@ class Block(CoreBlock, Drawable):
for ports, has_busses in zip((self.active_sources, self.active_sinks), bussified):
if not ports:
continue
- port_separation = Constants.PORT_SEPARATION if not has_busses else ports[0].height + Constants.PORT_SPACING
- offset = (self.height - (len(ports) - 1) * port_separation - ports[0].height) / 2
+ port_separation = Constants.PORT_SEPARATION if not has_busses else ports[
+ 0].height + Constants.PORT_SPACING
+ offset = (self.height - (len(ports) - 1) *
+ port_separation - ports[0].height) / 2
for port in ports:
port.create_shapes()
port.coordinate = {
@@ -148,7 +151,8 @@ class Block(CoreBlock, Drawable):
270: (offset, +self.width),
}[port.connector_direction]
- offset += Constants.PORT_SEPARATION if not has_busses else port.height + Constants.PORT_SPACING
+ offset += Constants.PORT_SEPARATION if not has_busses else port.height + \
+ Constants.PORT_SPACING
def create_labels(self, cr=None):
"""Create the labels for the signal block."""
@@ -178,7 +182,8 @@ class Block(CoreBlock, Drawable):
markups = [param.format_block_surface_markup()
for param in self.params.values() if (param.hide not in ('all', 'part') or (param.dtype == 'id' and force_show_id))]
else:
- markups = ['<span font_desc="{font}"><b>key: </b>{key}</span>'.format(font=Constants.PARAM_FONT, key=self.key)]
+ markups = ['<span font_desc="{font}"><b>key: </b>{key}</span>'.format(
+ font=Constants.PARAM_FONT, key=self.key)]
params_layout.set_spacing(Constants.LABEL_SEPARATION * Pango.SCALE)
params_layout.set_markup('\n'.join(markups))
@@ -197,12 +202,13 @@ class Block(CoreBlock, Drawable):
self.create_port_labels()
def get_min_height_for_ports(ports):
- min_height = 2 * Constants.PORT_BORDER_SEPARATION + len(ports) * Constants.PORT_SEPARATION
+ min_height = 2 * Constants.PORT_BORDER_SEPARATION + \
+ len(ports) * Constants.PORT_SEPARATION
# If any of the ports are bus ports - make the min height larger
if any([p.dtype == 'bus' for p in ports]):
min_height = 2 * Constants.PORT_BORDER_SEPARATION + sum(
port.height + Constants.PORT_SPACING for port in ports if port.dtype == 'bus'
- ) - Constants.PORT_SPACING
+ ) - Constants.PORT_SPACING
else:
if ports:
@@ -213,11 +219,13 @@ class Block(CoreBlock, Drawable):
get_min_height_for_ports(self.active_sinks),
get_min_height_for_ports(self.active_sources))
- self.width, self.height = width, height = Utils.align_to_grid((width, height))
+ self.width, self.height = width, height = Utils.align_to_grid(
+ (width, height))
self._surface_layouts_offsets = [
(0, (height - label_height) / 2.0),
- (0, (height - label_height) / 2.0 + Constants.LABEL_SEPARATION + title_height / Pango.SCALE)
+ (0, (height - label_height) / 2.0 +
+ Constants.LABEL_SEPARATION + title_height / Pango.SCALE)
]
title_layout.set_width(width * Pango.SCALE)
@@ -243,7 +251,8 @@ class Block(CoreBlock, Drawable):
complexity = utils.flow_graph_complexity.calculate(self.parent)
markups.append(
'<span foreground="#444" size="medium" font_desc="{font}">'
- '<b>Complexity: {num}bal</b></span>'.format(num=Utils.num_to_str(complexity), font=Constants.BLOCK_FONT)
+ '<b>Complexity: {num}bal</b></span>'.format(
+ num=Utils.num_to_str(complexity), font=Constants.BLOCK_FONT)
)
comment = self.comment # Returns None if there are no comments
if comment:
@@ -303,7 +312,8 @@ class Block(CoreBlock, Drawable):
for port in self.active_ports():
port_selected = port.what_is_selected(
coor=[a - b for a, b in zip(coor, self.coordinate)],
- coor_m=[a - b for a, b in zip(coor, self.coordinate)] if coor_m is not None else None
+ coor_m=[
+ a - b for a, b in zip(coor, self.coordinate)] if coor_m is not None else None
)
if port_selected:
return port_selected
@@ -359,7 +369,8 @@ class Block(CoreBlock, Drawable):
true for change
"""
type_templates = ' '.join(p.dtype for p in self.params.values()) + ' '
- type_templates += ' '.join(p.get_raw('dtype') for p in (self.sinks + self.sources))
+ type_templates += ' '.join(p.get_raw('dtype')
+ for p in (self.sinks + self.sources))
type_param = None
for key, param in self.params.items():
if not param.is_enum():
@@ -396,7 +407,8 @@ class Block(CoreBlock, Drawable):
"""
changed = False
# Concat the nports string from the private nports settings of all ports
- nports_str = ' '.join(str(port.get_raw('multiplicity')) for port in self.ports())
+ nports_str = ' '.join(str(port.get_raw('multiplicity'))
+ for port in self.ports())
# Modify all params whose keys appear in the nports string
for key, param in self.params.items():
if param.is_enum() or param.key not in nports_str:
diff --git a/grc/gui/canvas/colors.py b/grc/gui/canvas/colors.py
index 2ab4933761..89f5025d0e 100644
--- a/grc/gui/canvas/colors.py
+++ b/grc/gui/canvas/colors.py
@@ -25,6 +25,7 @@ def get_color(color_code):
# fg colors
#################################################################################
+
HIGHLIGHT_COLOR = get_color('#00FFFF')
BORDER_COLOR = get_color('#616161')
BORDER_COLOR_DISABLED = get_color('#888888')
@@ -62,8 +63,10 @@ DEFAULT_DOMAIN_COLOR = get_color('#777777')
# port colors
#################################################################################
-PORT_TYPE_TO_COLOR = {key: get_color(color) for name, key, sizeof, color in Constants.CORE_TYPES}
-PORT_TYPE_TO_COLOR.update((key, get_color(color)) for key, (_, color) in Constants.ALIAS_TYPES.items())
+PORT_TYPE_TO_COLOR = {key: get_color(
+ color) for name, key, sizeof, color in Constants.CORE_TYPES}
+PORT_TYPE_TO_COLOR.update((key, get_color(color))
+ for key, (_, color) in Constants.ALIAS_TYPES.items())
#################################################################################
@@ -109,4 +112,3 @@ LIGHT_THEME_STYLES = b"""
#enum_custom { background-color: #EEEEEE; }
"""
-
diff --git a/grc/gui/canvas/connection.py b/grc/gui/canvas/connection.py
index 316ecbdd09..be5db73b65 100644
--- a/grc/gui/canvas/connection.py
+++ b/grc/gui/canvas/connection.py
@@ -73,11 +73,13 @@ class Connection(CoreConnection, Drawable):
# first two components relative to source connector, rest relative to sink connector
self._rel_points = [
- rotate((15, 0), source.rotation), # line from 0,0 to here, bezier curve start
+ # line from 0,0 to here, bezier curve start
+ rotate((15, 0), source.rotation),
rotate((50, 0), source.rotation), # bezier curve control point 1
rotate((-50, 0), sink.rotation), # bezier curve control point 2
rotate((-15, 0), sink.rotation), # bezier curve end
- rotate((-CONNECTOR_ARROW_HEIGHT, 0), sink.rotation), # line to arrow head
+ rotate((-CONNECTOR_ARROW_HEIGHT, 0),
+ sink.rotation), # line to arrow head
]
self._current_coordinates = None # triggers _make_path()
@@ -110,7 +112,8 @@ class Connection(CoreConnection, Drawable):
# make rel_point all relative to source connector
p0 = 0, 0 # x_start - x_pos, y_start - y_pos
- p1, p2, (dx_e1, dy_e1), (dx_e2, dy_e2), (dx_e3, dy_e3) = self._rel_points
+ p1, p2, (dx_e1, dy_e1), (dx_e2, dy_e2), (dx_e3,
+ dy_e3) = self._rel_points
p3 = x_e + dx_e1, y_e + dy_e1
p4 = x_e + dx_e2, y_e + dy_e2
p5 = x_e + dx_e3, y_e + dy_e3
@@ -137,7 +140,8 @@ class Connection(CoreConnection, Drawable):
self.create_shapes() # triggers _make_path() call below
self._current_port_rotations = port_rotations
- new_coordinates = (source.parent_block.coordinate, sink.parent_block.coordinate)
+ new_coordinates = (source.parent_block.coordinate,
+ sink.parent_block.coordinate)
if self._current_coordinates != new_coordinates:
self._make_path(cr)
self._current_coordinates = new_coordinates
@@ -175,7 +179,7 @@ class Connection(CoreConnection, Drawable):
cr.set_source_rgba(*color2)
cr.rotate(self._arrow_rotation)
cr.rel_move_to(CONNECTOR_ARROW_HEIGHT, 0)
- cr.rel_line_to(-CONNECTOR_ARROW_HEIGHT, -CONNECTOR_ARROW_BASE/2)
+ cr.rel_line_to(-CONNECTOR_ARROW_HEIGHT, -CONNECTOR_ARROW_BASE / 2)
cr.rel_line_to(0, CONNECTOR_ARROW_BASE)
cr.close_path()
cr.fill()
@@ -238,4 +242,5 @@ class DummyCoreConnection(object):
def has_real_sink(self):
return self.sink_port is not self._dummy_port
+
DummyConnection = Connection.make_cls_with_base(DummyCoreConnection)
diff --git a/grc/gui/canvas/flowgraph.py b/grc/gui/canvas/flowgraph.py
index cb63f578ac..7c086f3641 100644
--- a/grc/gui/canvas/flowgraph.py
+++ b/grc/gui/canvas/flowgraph.py
@@ -125,7 +125,8 @@ class FlowGraph(CoreFlowgraph, Drawable):
editor.open_editor()
except Exception as e:
# Problem launching the editor. Need to select a new editor.
- Messages.send('>>> Error opening an external editor. Please select a different editor.\n')
+ Messages.send(
+ '>>> Error opening an external editor. Please select a different editor.\n')
# Reset the editor to force the user to select a new one.
self.parent_platform.config.editor = ''
@@ -153,10 +154,13 @@ class FlowGraph(CoreFlowgraph, Drawable):
# calculate the position coordinate
h_adj = scroll_pane.get_hadjustment()
v_adj = scroll_pane.get_vadjustment()
- if coor is None: coor = (
- int(random.uniform(.25, .75)*h_adj.get_page_size() + h_adj.get_value()),
- int(random.uniform(.25, .75)*v_adj.get_page_size() + v_adj.get_value()),
- )
+ if coor is None:
+ coor = (
+ int(random.uniform(.25, .75) *
+ h_adj.get_page_size() + h_adj.get_value()),
+ int(random.uniform(.25, .75) *
+ v_adj.get_page_size() + v_adj.get_value()),
+ )
# get the new block
block = self.new_block(key)
block.coordinate = coor
@@ -218,17 +222,17 @@ class FlowGraph(CoreFlowgraph, Drawable):
Returns:
the clipboard
"""
- #get selected blocks
+ # get selected blocks
blocks = list(self.selected_blocks())
if not blocks:
return None
- #calc x and y min
+ # calc x and y min
x_min, y_min = blocks[0].coordinate
for block in blocks:
x, y = block.coordinate
x_min = min(x, x_min)
y_min = min(y, y_min)
- #get connections between selected blocks
+ # get connections between selected blocks
connections = list(filter(
lambda c: c.source_block in blocks and c.sink_block in blocks,
self.connections,
@@ -281,7 +285,8 @@ class FlowGraph(CoreFlowgraph, Drawable):
block.move((x_off, y_off))
while any(Utils.align_to_grid(block.coordinate) == Utils.align_to_grid(other.coordinate)
for other in self.blocks if other is not block):
- block.move((Constants.CANVAS_GRID_SIZE, Constants.CANVAS_GRID_SIZE))
+ block.move((Constants.CANVAS_GRID_SIZE,
+ Constants.CANVAS_GRID_SIZE))
# shift all following blocks
x_off += Constants.CANVAS_GRID_SIZE
y_off += Constants.CANVAS_GRID_SIZE
@@ -353,15 +358,16 @@ class FlowGraph(CoreFlowgraph, Drawable):
if not blocks:
return
- min_x, min_y = self.selected_block.coordinate
+ min_x, min_y = self.selected_block.coordinate
for selected_block in blocks:
x, y = selected_block.coordinate
min_x, min_y = min(min_x, x), min(min_y, y)
# Sanitize delta_coordinate so that blocks don't move to negative coordinate
- delta_coordinate = max(delta_coordinate[0],-min_x), max(delta_coordinate[1], -min_y)
+ delta_coordinate = max(
+ delta_coordinate[0], -min_x), max(delta_coordinate[1], -min_y)
- # Move selected blocks
+ # Move selected blocks
for selected_block in blocks:
selected_block.move(delta_coordinate)
self.element_moved = True
@@ -388,15 +394,15 @@ class FlowGraph(CoreFlowgraph, Drawable):
x += selected_block.width
y += selected_block.height
max_x, max_y = max(max_x, x), max(max_y, y)
- ctr_x, ctr_y = (max_x + min_x)/2, (max_y + min_y)/2
+ ctr_x, ctr_y = (max_x + min_x) / 2, (max_y + min_y) / 2
# align the blocks as requested
transform = {
Actions.BLOCK_VALIGN_TOP: lambda x, y, w, h: (x, min_y),
- Actions.BLOCK_VALIGN_MIDDLE: lambda x, y, w, h: (x, ctr_y - h/2),
+ Actions.BLOCK_VALIGN_MIDDLE: lambda x, y, w, h: (x, ctr_y - h / 2),
Actions.BLOCK_VALIGN_BOTTOM: lambda x, y, w, h: (x, max_y - h),
Actions.BLOCK_HALIGN_LEFT: lambda x, y, w, h: (min_x, y),
- Actions.BLOCK_HALIGN_CENTER: lambda x, y, w, h: (ctr_x-w/2, y),
+ Actions.BLOCK_HALIGN_CENTER: lambda x, y, w, h: (ctr_x - w / 2, y),
Actions.BLOCK_HALIGN_RIGHT: lambda x, y, w, h: (max_x - w, y),
}.get(calling_action, lambda *args: args)
@@ -419,21 +425,22 @@ class FlowGraph(CoreFlowgraph, Drawable):
"""
if not any(self.selected_blocks()):
return False
- #initialize min and max coordinates
+ # initialize min and max coordinates
min_x, min_y = max_x, max_y = self.selected_block.coordinate
# rotate each selected block, and find min/max coordinate
for selected_block in self.selected_blocks():
selected_block.rotate(rotation)
- #update the min/max coordinate
+ # update the min/max coordinate
x, y = selected_block.coordinate
min_x, min_y = min(min_x, x), min(min_y, y)
max_x, max_y = max(max_x, x), max(max_y, y)
- #calculate center point of selected blocks
- ctr_x, ctr_y = (max_x + min_x)/2, (max_y + min_y)/2
- #rotate the blocks around the center point
+ # calculate center point of selected blocks
+ ctr_x, ctr_y = (max_x + min_x) / 2, (max_y + min_y) / 2
+ # rotate the blocks around the center point
for selected_block in self.selected_blocks():
x, y = selected_block.coordinate
- x, y = Utils.get_rotated_coordinate((x - ctr_x, y - ctr_y), rotation)
+ x, y = Utils.get_rotated_coordinate(
+ (x - ctr_x, y - ctr_y), rotation)
selected_block.coordinate = (x + ctr_x, y + ctr_y)
return True
@@ -496,7 +503,7 @@ class FlowGraph(CoreFlowgraph, Drawable):
element.create_labels(cr)
def create_shapes(self):
- #TODO - this is a workaround for bus ports not having a proper coordinate
+ # TODO - this is a workaround for bus ports not having a proper coordinate
# until the shape is drawn. The workaround is to draw blocks before connections
for element in filter(lambda x: x.is_block, self._elements_to_draw):
@@ -582,7 +589,8 @@ class FlowGraph(CoreFlowgraph, Drawable):
else: # called from a mouse release
if not self.element_moved and (not self.selected_elements or self.drawing_area.ctrl_mask) and not self._new_connection:
- selected_elements = self.what_is_selected(self.coordinate, self.press_coor)
+ selected_elements = self.what_is_selected(
+ self.coordinate, self.press_coor)
# this selection and the last were ports, try to connect them
if self.make_connection():
@@ -635,7 +643,8 @@ class FlowGraph(CoreFlowgraph, Drawable):
if selected_port and selected_port.is_source:
selected.remove(selected_port.parent_block)
- self._new_connection = DummyConnection(selected_port, coordinate=coor)
+ self._new_connection = DummyConnection(
+ selected_port, coordinate=coor)
self.drawing_area.queue_draw()
# update selected ports
if selected_port is not self._new_selected_port:
@@ -806,19 +815,21 @@ class FlowGraph(CoreFlowgraph, Drawable):
dX, dY = x - X, y - Y
if Actions.TOGGLE_SNAP_TO_GRID.get_active() or self.drawing_area.mod1_mask:
- dX, dY = int(round(dX / Constants.CANVAS_GRID_SIZE)), int(round(dY / Constants.CANVAS_GRID_SIZE))
+ dX, dY = int(round(dX / Constants.CANVAS_GRID_SIZE)
+ ), int(round(dY / Constants.CANVAS_GRID_SIZE))
dX, dY = dX * Constants.CANVAS_GRID_SIZE, dY * Constants.CANVAS_GRID_SIZE
else:
dX, dY = int(round(dX)), int(round(dY))
if dX != 0 or dY != 0:
self.move_selected((dX, dY))
- self.coordinate = (X+dX, Y+dY)
+ self.coordinate = (X + dX, Y + dY)
redraw = True
return redraw
def get_extents(self):
show_comments = Actions.TOGGLE_SHOW_BLOCK_COMMENTS.get_active()
+
def sub_extents():
for element in self._elements_to_draw:
yield element.get_extents()
@@ -828,5 +839,6 @@ class FlowGraph(CoreFlowgraph, Drawable):
extent = 10000000, 10000000, 0, 0
cmps = (min, min, max, max)
for sub_extent in sub_extents():
- extent = [cmp(xy, e_xy) for cmp, xy, e_xy in zip(cmps, extent, sub_extent)]
+ extent = [cmp(xy, e_xy)
+ for cmp, xy, e_xy in zip(cmps, extent, sub_extent)]
return tuple(extent)
diff --git a/grc/gui/canvas/param.py b/grc/gui/canvas/param.py
index 6b33ef223c..488ca7a5c3 100644
--- a/grc/gui/canvas/param.py
+++ b/grc/gui/canvas/param.py
@@ -86,20 +86,20 @@ class Param(CoreParam):
tooltip_lines.extend(' * ' + msg for msg in errors)
return '\n'.join(tooltip_lines)
-
-
##################################################
# Truncate helper method
##################################################
+
def truncate(self, string, style=0):
max_len = max(27 - len(self.name), 3)
if len(string) > max_len:
if style < 0: # Front truncate
- string = '...' + string[3-max_len:]
+ string = '...' + string[3 - max_len:]
elif style == 0: # Center truncate
- string = string[:max_len//2 - 3] + '...' + string[-max_len//2:]
+ string = string[:max_len // 2 - 3] + \
+ '...' + string[-max_len // 2:]
elif style > 0: # Rear truncate
- string = string[:max_len-3] + '...'
+ string = string[:max_len - 3] + '...'
return string
def pretty_print(self):
@@ -183,5 +183,5 @@ class Param(CoreParam):
display_value = expr_string
return '<span {foreground} font_desc="{font}"><b>{label}:</b> {value}</span>'.format(
- foreground='foreground="red"' if not self.is_valid() else '', font=Constants.PARAM_FONT,
+ foreground='foreground="red"' if not self.is_valid() else '', font=Constants.PARAM_FONT,
label=Utils.encode(self.name), value=display_value)
diff --git a/grc/gui/canvas/port.py b/grc/gui/canvas/port.py
index d963964cdc..f78fd62179 100644
--- a/grc/gui/canvas/port.py
+++ b/grc/gui/canvas/port.py
@@ -68,9 +68,11 @@ class Port(CorePort, Drawable):
color = colors.PORT_TYPE_TO_COLOR.get('message')
else:
self._font_color[-1] = 1.0
- color = colors.PORT_TYPE_TO_COLOR.get(self.dtype) or colors.PORT_TYPE_TO_COLOR.get('')
+ color = colors.PORT_TYPE_TO_COLOR.get(
+ self.dtype) or colors.PORT_TYPE_TO_COLOR.get('')
if self.vlen > 1:
- dark = (0, 0, 30 / 255.0, 50 / 255.0, 70 / 255.0)[min(4, self.vlen)]
+ dark = (0, 0, 30 / 255.0, 50 / 255.0,
+ 70 / 255.0)[min(4, self.vlen)]
color = tuple(max(c - dark, 0) for c in color)
self._bg_color = color
self._border_color = tuple(max(c - 0.3, 0) for c in color)
@@ -84,8 +86,8 @@ class Port(CorePort, Drawable):
self.bounds_from_area(self._area)
self._connector_coordinate = {
- 0: (self.width, self.height / 2),
- 90: (self.height / 2, 0),
+ 0: (self.width, self.height / 2),
+ 90: (self.height / 2, 0),
180: (0, self.height / 2),
270: (self.height / 2, self.width)
}[self.connector_direction]
@@ -112,7 +114,8 @@ class Port(CorePort, Drawable):
label_width, label_height = self.label_layout.get_size()
self.width = 2 * Constants.PORT_LABEL_PADDING + label_width / Pango.SCALE
- self.height = (2 * Constants.PORT_LABEL_PADDING + label_height*(3 if self.dtype == 'bus' else 1)) / Pango.SCALE
+ self.height = (2 * Constants.PORT_LABEL_PADDING + label_height *
+ (3 if self.dtype == 'bus' else 1)) / Pango.SCALE
self._label_layout_offsets = [0, Constants.PORT_LABEL_PADDING]
self.height += self.height % 2 # uneven height