diff options
Diffstat (limited to 'grc')
-rw-r--r-- | grc/blocks/CMakeLists.txt | 21 | ||||
-rw-r--r-- | grc/blocks/options.xml | 58 | ||||
-rw-r--r-- | grc/core/Block.py | 3 | ||||
-rw-r--r-- | grc/core/Constants.py | 3 | ||||
-rw-r--r-- | grc/core/Param.py | 64 | ||||
-rw-r--r-- | grc/core/generator/Generator.py | 4 | ||||
-rw-r--r-- | grc/core/generator/flow_graph.tmpl | 53 | ||||
-rw-r--r-- | grc/gui/Colors.py | 3 | ||||
-rw-r--r-- | grc/gui/MainWindow.py | 21 |
9 files changed, 61 insertions, 169 deletions
diff --git a/grc/blocks/CMakeLists.txt b/grc/blocks/CMakeLists.txt index eaa57970a6..d46b1febbe 100644 --- a/grc/blocks/CMakeLists.txt +++ b/grc/blocks/CMakeLists.txt @@ -22,6 +22,19 @@ include(GrPython) file(GLOB xml_files "*.xml") +macro(REPLACE_IN_FILE _xml_block match replace) + set(xml_block_src "${CMAKE_CURRENT_SOURCE_DIR}/${_xml_block}") + set(xml_block "${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}") + + list(REMOVE_ITEM xml_files "${xml_block_src}") + file(READ "${xml_block_src}" xml_block_src_text) + string(REPLACE "${match}" "${replace}" + xml_block_text "${xml_block_src_text}") + file(WRITE "${xml_block}" "${xml_block_text}") + + list(APPEND generated_xml_files "${xml_block}") +endmacro() + macro(GEN_BLOCK_XML _generator _xml_block) set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator}) set(xml_block ${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}) @@ -30,9 +43,13 @@ macro(GEN_BLOCK_XML _generator _xml_block) DEPENDS ${generator} OUTPUT ${xml_block} COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block} ) -endmacro(GEN_BLOCK_XML) +endmacro() + +GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml) -GEN_BLOCK_XML(variable_struct.xml.py variable_struct.xml) +if(DESIRED_QT_VERSION EQUAL 4) + REPLACE_IN_FILE(options.xml PyQt5 PyQt4) +endif() add_custom_target(grc_generated_xml ALL DEPENDS ${generated_xml_files}) diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml index 55f411884d..252a0b2e2d 100644 --- a/grc/blocks/options.xml +++ b/grc/blocks/options.xml @@ -11,12 +11,8 @@ <key>options</key> <import>from gnuradio import gr</import> <import>from gnuradio.filter import firdes</import> - <import>#if $generate_options() == 'wx_gui' -from grc_gnuradio import wxgui as grc_wxgui -import wx -#end if -#if $generate_options() == 'qt_gui' -from PyQt4 import Qt + <import>#if $generate_options() == 'qt_gui' +from PyQt5 import Qt import sys #end if #if not $generate_options().startswith('hb') @@ -65,10 +61,6 @@ else: self.stop(); self.wait()</callback> <key>qt_gui</key> </option> <option> - <name>WX GUI</name> - <key>wx_gui</key> - </option> - <option> <name>No GUI</name> <key>no_gui</key> </option> @@ -108,17 +100,7 @@ else: self.stop(); self.wait()</callback> <key>run</key> <value>True</value> <type>bool</type> - <hide> -#if $generate_options() in ('qt_gui', 'wx_gui') - #if $run() - part - #else - none - #end if -#else - all -#end if - </hide> + <hide>#if $generate_options() == 'qt_gui' then ('part' if $run() else 'none') else 'all'#</hide> <option> <name>Autostart</name> <key>True</key> @@ -133,26 +115,14 @@ else: self.stop(); self.wait()</callback> <key>max_nouts</key> <value>0</value> <type>int</type> - <hide>#if $generate_options().startswith('hb') -all#slurp -#elif $max_nouts() -none#slurp -#else -part#slurp -#end if</hide> + <hide>#if $generate_options().startswith('hb') then 'all' else ('none' if $max_nouts() else 'part')#</hide> </param> <param> <name>Realtime Scheduling</name> <key>realtime_scheduling</key> <value></value> <type>enum</type> - <hide>#if $generate_options().startswith('hb') -all#slurp -#elif $realtime_scheduling() -none#slurp -#else -part#slurp -#end if</hide> + <hide>#if $generate_options().startswith('hb') then 'all' else ('none' if $realtime_scheduling() else 'part')#</hide> <option> <name>Off</name> <key></key> @@ -167,17 +137,7 @@ part#slurp <key>qt_qss_theme</key> <value></value> <type>file_open</type> - <hide> -#if $generate_options() in ('qt_gui',) - #if $qt_qss_theme() - none - #else - part - #end if -#else - all -#end if -</hide> + <hide>#if $generate_options() == 'qt_gui' then ('none' if $qt_qss_theme() else 'part') else 'all'#</hide> </param> <param> <name>Thread-safe setters</name> @@ -200,11 +160,7 @@ part#slurp <key>run_command</key> <value>{python} -u {filename}</value> <type>string</type> - <hide>#if $generate_options().startswith('hb') -all#slurp -#else -part#slurp -#end if</hide> + <hide>#if $generate_options().startswith('hb') then 'all' else 'part'</hide> <tab>Advanced</tab> </param> <param> diff --git a/grc/core/Block.py b/grc/core/Block.py index e7e4a8215a..9a1d72c2de 100644 --- a/grc/core/Block.py +++ b/grc/core/Block.py @@ -31,7 +31,7 @@ from Cheetah.Template import Template from . import utils from . Constants import ( - BLOCK_FLAG_NEED_QT_GUI, BLOCK_FLAG_NEED_WX_GUI, + BLOCK_FLAG_NEED_QT_GUI, ADVANCED_PARAM_TAB, BLOCK_FLAG_THROTTLE, BLOCK_FLAG_DISABLE_BYPASS, BLOCK_FLAG_DEPRECATED, @@ -245,7 +245,6 @@ class Block(Element): self.add_error_message("Can't generate this block in mode: {} ".format( repr(current_generate_option))) - check_generate_mode('WX GUI', BLOCK_FLAG_NEED_WX_GUI, ('wx_gui',)) check_generate_mode('QT GUI', BLOCK_FLAG_NEED_QT_GUI, ('qt_gui', 'hb_qt_gui')) def _validate_var_value(self): diff --git a/grc/core/Constants.py b/grc/core/Constants.py index 394150529b..caf301be60 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -52,7 +52,6 @@ DEFAULT_DOMAIN = GR_STREAM_DOMAIN BLOCK_FLAG_THROTTLE = 'throttle' BLOCK_FLAG_DISABLE_BYPASS = 'disable_bypass' BLOCK_FLAG_NEED_QT_GUI = 'need_qt_gui' -BLOCK_FLAG_NEED_WX_GUI = 'need_wx_gui' BLOCK_FLAG_DEPRECATED = 'deprecated' # File creation modes @@ -67,7 +66,7 @@ PARAM_TYPE_NAMES = ( 'hex', 'string', 'bool', 'file_open', 'file_save', '_multiline', '_multiline_python_external', 'id', 'stream_id', - 'grid_pos', 'notebook', 'gui_hint', + 'gui_hint', 'import', ) diff --git a/grc/core/Param.py b/grc/core/Param.py index 6d947c3615..31393b1d79 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -29,7 +29,7 @@ from . import Constants from .Element import Element, nop_write # Blacklist certain ids, its not complete, but should help -ID_BLACKLIST = ['self', 'options', 'gr', 'blks2', 'wxgui', 'wx', 'math', 'forms', 'firdes'] + dir(builtins) +ID_BLACKLIST = ['self', 'options', 'gr', 'blks2', 'math', 'firdes'] + dir(builtins) try: from gnuradio import gr ID_BLACKLIST.extend(attr for attr in dir(gr.top_block()) if not attr.startswith('_')) @@ -155,9 +155,6 @@ class Param(Element): return 'part' except: pass - # Hide empty grid positions - if self.key in ('grid_pos', 'notebook') and not self.get_value(): - return 'part' return hide def validate(self): @@ -352,65 +349,6 @@ class Param(Element): return self._ws return GuiHint(widget_str) ######################### - # Grid Position Type - ######################### - elif t == 'grid_pos': - if not v: - # Allow for empty grid pos - return '' - e = self.parent_flowgraph.evaluate(v) - if not isinstance(e, (list, tuple)) or len(e) != 4 or not all([isinstance(ei, int) for ei in e]): - raise Exception('A grid position must be a list of 4 integers.') - row, col, row_span, col_span = e - # Check row, col - if row < 0 or col < 0: - raise Exception('Row and column must be non-negative.') - # Check row span, col span - if row_span <= 0 or col_span <= 0: - raise Exception('Row and column span must be greater than zero.') - # Get hostage cell parent - try: - my_parent = self.parent.get_param('notebook').evaluate() - except: - my_parent = '' - # Calculate hostage cells - for r in range(row_span): - for c in range(col_span): - self._hostage_cells.append((my_parent, (row+r, col+c))) - # Avoid collisions - params = [p for p in self.get_all_params('grid_pos') if p is not self] - for param in params: - for parent, cell in param._hostage_cells: - if (parent, cell) in self._hostage_cells: - raise Exception('Another graphical element is using parent "{}", cell "{}".'.format(str(parent), str(cell))) - return e - ######################### - # Notebook Page Type - ######################### - elif t == 'notebook': - if not v: - # Allow for empty notebook - return '' - - # Get a list of all notebooks - notebook_blocks = [b for b in self.parent_flowgraph.get_enabled_blocks() if b.key == 'notebook'] - # Check for notebook param syntax - try: - notebook_id, page_index = map(str.strip, v.split(',')) - except: - raise Exception('Bad notebook page format.') - # Check that the notebook id is valid - try: - notebook_block = [b for b in notebook_blocks if b.get_id() == notebook_id][0] - except: - raise Exception('Notebook id "{}" is not an existing notebook id.'.format(notebook_id)) - - # Check that page index exists - if int(page_index) not in range(len(notebook_block.get_param('labels').evaluate())): - raise Exception('Page index "{}" is not a valid index number.'.format(page_index)) - return notebook_id, page_index - - ######################### # Import Type ######################### elif t == 'import': diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py index f042b4963c..8b073293ce 100644 --- a/grc/core/generator/Generator.py +++ b/grc/core/generator/Generator.py @@ -136,10 +136,6 @@ class TopBlockGenerator(object): def _get_block_sort_text(block): code = block.get_make().replace(block.get_id(), ' ') try: - code += block.get_param('notebook').get_value() # Older gui markup w/ wxgui - except: - pass - try: code += block.get_param('gui_hint').get_value() # Newer gui markup w/ qtgui except: pass diff --git a/grc/core/generator/flow_graph.tmpl b/grc/core/generator/flow_graph.tmpl index fd5546e459..b8913bb087 100644 --- a/grc/core/generator/flow_graph.tmpl +++ b/grc/core/generator/flow_graph.tmpl @@ -35,9 +35,13 @@ $DIVIDER import threading #end if +#if $generate_options == 'qt_gui' +from distutils.version import StrictVersion +#end if + ## Call XInitThreads as the _very_ first thing. ## After some Qt import, it's too late -#if $generate_options in ('wx_gui', 'qt_gui') +#if $generate_options == 'qt_gui' if __name__ == '__main__': import ctypes import sys @@ -71,29 +75,11 @@ $imp ##Create Class ## Write the class declaration for a top or hier block. ## The parameter names are the arguments to __init__. -## Determine the absolute icon path (wx gui only). ## Setup the IO signature (hier block only). ######################################################## #set $class_name = $flow_graph.get_option('id') #set $param_str = ', '.join(['self'] + ['%s=%s'%(param.get_id(), param.get_make()) for param in $parameters]) -#if $generate_options == 'wx_gui' - #from gi.repository import Gtk - #try: - #set $icon = Gtk.IconTheme().load_icon('gnuradio-grc', 256, 0) - #except: - #set $icon = '' - #end try - - -class $(class_name)(grc_wxgui.top_block_gui): - - def __init__($param_str): - grc_wxgui.top_block_gui.__init__(self, title="$title") - #if $icon - _icon_path = "$icon.get_filename()" - self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) - #end if -#elif $generate_options == 'qt_gui' +#if $generate_options == 'qt_gui' class $(class_name)(gr.top_block, Qt.QWidget): @@ -119,7 +105,14 @@ class $(class_name)(gr.top_block, Qt.QWidget): self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "$class_name") - self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + try: + if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + else: + self.restoreGeometry(self.settings.value("geometry")) + except: + pass #elif $generate_options == 'no_gui' @@ -359,20 +352,8 @@ def main(top_block_cls=$(class_name), options=None): print "Error: failed to enable real-time scheduling." #end if - #if $generate_options == 'wx_gui' - tb = top_block_cls($(', '.join($params_eq_list))) - #if $flow_graph.get_option('max_nouts') - tb.Run($flow_graph.get_option('run'), $flow_graph.get_option('max_nouts')) - #else - tb.Start($flow_graph.get_option('run')) - #for $m in $monitors - (tb.$m.get_id()).start() - #end for - tb.Wait() - #end if - #elif $generate_options == 'qt_gui' - from distutils.version import StrictVersion - if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + #if $generate_options == 'qt_gui' + if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): style = gr.prefs().get_string('qtgui', 'style', 'raster') Qt.QApplication.setGraphicsSystem(style) qapp = Qt.QApplication(sys.argv) @@ -393,7 +374,7 @@ def main(top_block_cls=$(class_name), options=None): def quitting(): tb.stop() tb.wait() - qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.aboutToQuit.connect(quitting) #for $m in $monitors if 'en' in $m.params: if $m.params['en'].get_value(): diff --git a/grc/gui/Colors.py b/grc/gui/Colors.py index acc7f22c44..01c461ada5 100644 --- a/grc/gui/Colors.py +++ b/grc/gui/Colors.py @@ -96,7 +96,6 @@ SHORT_VECTOR_COLOR_SPEC = _color_parse('#CCCC33') BYTE_VECTOR_COLOR_SPEC = _color_parse('#CC66CC') PARAM_ENTRY_COLORS = { - # Number types 'complex': COMPLEX_COLOR_SPEC, 'real': FLOAT_COLOR_SPEC, @@ -115,8 +114,6 @@ PARAM_ENTRY_COLORS = { 'string': BYTE_VECTOR_COLOR_SPEC, 'id': ID_COLOR_SPEC, 'stream_id': ID_COLOR_SPEC, - 'grid_pos': INT_VECTOR_COLOR_SPEC, - 'notebook': INT_VECTOR_COLOR_SPEC, 'raw': WILDCARD_COLOR_SPEC, } diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py index 61144386b4..3d4bf10308 100644 --- a/grc/gui/MainWindow.py +++ b/grc/gui/MainWindow.py @@ -179,26 +179,35 @@ class MainWindow(Gtk.Window): # to be hidden as well. if panel == self.BLOCKS: - self.btwin.set_visible(visibility) + if visibility: + self.btwin.show() + else: + self.btwin.hide() elif panel == self.CONSOLE: - self.console_window.set_visible(visibility) + if visibility: + self.console_window.show() + else: + self.console_window.hide() elif panel == self.VARIABLES: - self.vars.set_visible(visibility) + if visibility: + self.vars.show() + else: + self.vars.hide() else: return if self.variable_panel_sidebar: # If both the variable editor and block panels are hidden, hide the right container - if not self.btwin.get_visible() and not self.vars.get_visible(): + if not (self.btwin.get_property('visible')) and not (self.vars.get_property('visible')): self.right.hide() else: self.right.show() else: - if not self.btwin.get_visible(): + if not (self.btwin.get_property('visible')): self.right.hide() else: self.right.show() - if not self.vars.get_visible() and not self.console_window.get_visible(): + if not (self.vars.get_property('visible')) and not (self.console_window.get_property('visible')): self.left_subpanel.hide() else: self.left_subpanel.show() |