id: qtgui_tab_widget
label: QT GUI Tab Widget
flags: [show_id, python, cpp ]

parameters:
-   id: num_tabs
    label: Num Tabs
    dtype: enum
    default: '1'
    options: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13',
        '14', '15', '16', '17', '18', '19', '20']
-   id: label0
    label: Label 0
    dtype: string
    default: Tab 0
    hide: ${ ('none' if int(num_tabs) > 0 else 'all') }
-   id: label1
    label: Label 1
    dtype: string
    default: Tab 1
    hide: ${ ('none' if int(num_tabs) > 1 else 'all') }
-   id: label2
    label: Label 2
    dtype: string
    default: Tab 2
    hide: ${ ('none' if int(num_tabs) > 2 else 'all') }
-   id: label3
    label: Label 3
    dtype: string
    default: Tab 3
    hide: ${ ('none' if int(num_tabs) > 3 else 'all') }
-   id: label4
    label: Label 4
    dtype: string
    default: Tab 4
    hide: ${ ('none' if int(num_tabs) > 4 else 'all') }
-   id: label5
    label: Label 5
    dtype: string
    default: Tab 5
    hide: ${ ('none' if int(num_tabs) > 5 else 'all') }
-   id: label6
    label: Label 6
    dtype: string
    default: Tab 6
    hide: ${ ('none' if int(num_tabs) > 6 else 'all') }
-   id: label7
    label: Label 7
    dtype: string
    default: Tab 7
    hide: ${ ('none' if int(num_tabs) > 7 else 'all') }
-   id: label8
    label: Label 8
    dtype: string
    default: Tab 8
    hide: ${ ('none' if int(num_tabs) > 8 else 'all') }
-   id: label9
    label: Label 9
    dtype: string
    default: Tab 9
    hide: ${ ('none' if int(num_tabs) > 9 else 'all') }
-   id: label10
    label: Label 10
    dtype: string
    default: Tab 10
    hide: ${ ('none' if int(num_tabs) > 10 else 'all') }
-   id: label11
    label: Label 11
    dtype: string
    default: Tab 11
    hide: ${ ('none' if int(num_tabs) > 11 else 'all') }
-   id: label12
    label: Label 12
    dtype: string
    default: Tab 12
    hide: ${ ('none' if int(num_tabs) > 12 else 'all') }
-   id: label13
    label: Label 13
    dtype: string
    default: Tab 13
    hide: ${ ('none' if int(num_tabs) > 13 else 'all') }
-   id: label14
    label: Label 14
    dtype: string
    default: Tab 14
    hide: ${ ('none' if int(num_tabs) > 14 else 'all') }
-   id: label15
    label: Label 15
    dtype: string
    default: Tab 15
    hide: ${ ('none' if int(num_tabs) > 15 else 'all') }
-   id: label16
    label: Label 16
    dtype: string
    default: Tab 16
    hide: ${ ('none' if int(num_tabs) > 16 else 'all') }
-   id: label17
    label: Label 17
    dtype: string
    default: Tab 17
    hide: ${ ('none' if int(num_tabs) > 17 else 'all') }
-   id: label18
    label: Label 18
    dtype: string
    default: Tab 18
    hide: ${ ('none' if int(num_tabs) > 18 else 'all') }
-   id: label19
    label: Label 19
    dtype: string
    default: Tab 19
    hide: ${ ('none' if int(num_tabs) > 19 else 'all') }
-   id: gui_hint
    label: GUI Hint
    dtype: gui_hint
    hide: part

templates:
    make: |-
        <%
            win = 'self.%s'%id
            all_labels = [label0, label1, label2, label3, label4,
                          label5, label6, label7, label8, label9,
                          label10, label11, label12, label13, label14,
                          label15, label16, label17, label18, label19][:int(num_tabs)]
        %>\
        Qt.QTabWidget()
        % for i, label in enumerate(all_labels):
        self.${id}_widget_${i} = Qt.QWidget()
        self.${id}_layout_${i} = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.${id}_widget_${i})
        self.${id}_grid_layout_${i} = Qt.QGridLayout()
        self.${id}_layout_${i}.addLayout(self.${id}_grid_layout_${i})
        ${win}.addTab(self.${id}_widget_${i}, ${label})
        % endfor
        ${gui_hint() % win}

cpp_templates:
  includes: ['#include <QTabWidget>']
  declarations: QTabWidget *${id};
  link: ['gnuradio::gnuradio-qtgui']
  make: |-
    <%
        win = '%s'%id
        all_labels = [label0, label1, label2, label3, label4,
                      label5, label6, label7, label8, label9,
                      label10, label11, label12, label13, label14,
                      label15, label16, label17, label18,label19][:int(num_tabs)]
    %>\
    ${id} = new QTabWidget();
    % for i,label in enumerate(all_labels):
    QWidget* ${id}_widget_${i} = new QWidget();
    QBoxLayout* ${id}_layout_${i} =new QBoxLayout(QBoxLayout::TopToBottom,${id}_widget_${i});
    QGridLayout* ${id}_grid_layout_${i} = new QGridLayout();
    ${id}_layout_${i}->addLayout(${id}_grid_layout_${i});
    ${win}->addTab(${id}_widget_${i},${label});
    % endfor
    ${gui_hint() % win}
 
documentation: |-
    This block creates a tabbed widget to organize other widgets. The ID of this block can be used as the tab_id in the GUI hints of other widgets.

    The GUI hint can be used to position the widget within the application. The hint is of the form [tab_id@tab_index]: [row, col, row_span, col_span]. Both the tab specification and the grid position are optional.

file_format: 1
