diff options
author | Volker Schroer <3470424+dl1ksv@users.noreply.github.com> | 2021-06-23 12:11:27 +0200 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-07-19 07:01:47 -0400 |
commit | f88f8a89b08b3268f44d4e25718a88b80d7d4692 (patch) | |
tree | 4ddf0b043d11a9b8321de1f71af3499017ebbc5a /grc/core/params/param.py | |
parent | ba8fff945d92ee53cf9c37a97e2eb50d3f368c76 (diff) |
grc: introduce gui_hint for cpp code generation
At the moment some qtgui windows do support only very simple gui hints, as
the parse_gui_hint in param.py generates independently of the output language
only python code.
This is fixed here, so the gui_hint() can be used in cpp code generation.
To test more complex gui hints the qtgui_tab_widget was extended to cpp.
After that compiling the generated cpp code for some examples led to
/usr/include/python3.9/object.h:206:23: Fehler: expected unqualified-id before »;« token
206 | PyType_Slot *slots; /* terminated by slot==0. */
This is a known error and can be fixed by
ifdef ENABLE_PYTHON
pragma push_macro("slots")
undef slots
include "Python.h"
pragma pop_macro("slots")
endif
instead of simply
ifdef ENABLE_PYTHON
include "Python.h"
endif
which was applied to the corresponding gr-qtgui header files.
Signed-off-by: Volker Schroer <3470424+dl1ksv@users.noreply.github.com>
Diffstat (limited to 'grc/core/params/param.py')
-rw-r--r-- | grc/core/params/param.py | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/grc/core/params/param.py b/grc/core/params/param.py index fae008935e..9e612abf91 100644 --- a/grc/core/params/param.py +++ b/grc/core/params/param.py @@ -403,20 +403,40 @@ class Param(Element): row, col, row_span, col_span = parse_pos() collision_detection(row, col, row_span, col_span) - widget_str = textwrap.dedent(""" - self.{layout}.addWidget({widget}, {row}, {col}, {row_span}, {col_span}) - for r in range({row}, {row_end}): - self.{layout}.setRowStretch(r, 1) - for c in range({col}, {col_end}): - self.{layout}.setColumnStretch(c, 1) - """.strip('\n')).format( - layout=layout, widget=widget, - row=row, row_span=row_span, row_end=row+row_span, - col=col, col_span=col_span, col_end=col+col_span, - ) + if self.parent_flowgraph.get_option('output_language') == 'python': + widget_str = textwrap.dedent(""" + self.{layout}.addWidget({widget}, {row}, {col}, {row_span}, {col_span}) + for r in range({row}, {row_end}): + self.{layout}.setRowStretch(r, 1) + for c in range({col}, {col_end}): + self.{layout}.setColumnStretch(c, 1) + """.strip('\n')).format( + layout=layout, widget=widget, + row=row, row_span=row_span, row_end=row+row_span, + col=col, col_span=col_span, col_end=col+col_span, + ) + elif self.parent_flowgraph.get_option('output_language') == 'cpp': + widget_str = textwrap.dedent(""" + {layout}->addWidget({widget}, {row}, {col}, {row_span}, {col_span}); + for(int r = {row};r < {row_end}; r++) + {layout}->setRowStretch(r, 1); + for(int c = {col}; c <{col_end}; c++) + {layout}->setColumnStretch(c, 1); + """.strip('\n')).format( + layout=layout, widget=widget, + row=row, row_span=row_span, row_end=row+row_span, + col=col, col_span=col_span, col_end=col+col_span, + ) + else: + widget_str = '' else: - widget_str = 'self.{layout}.addWidget({widget})'.format(layout=layout, widget=widget) + if self.parent_flowgraph.get_option('output_language') == 'python': + widget_str = 'self.{layout}.addWidget({widget})'.format(layout=layout, widget=widget) + elif self.parent_flowgraph.get_option('output_language') == 'cpp': + widget_str = '{layout}->addWidget({widget});'.format(layout=layout, widget=widget) + else: + widget_str = '' return widget_str |