

def set_layout_for_area(self, layout, q_dock_area, _toplevel_added=False, _toplevel_call=True):
    ' Applies a LayoutItem to the specified dock area.\n        '
    if isinstance(layout, PaneItem):
        if (not _toplevel_added):
            widget = self._prepare_toplevel_for_item(layout)
            if widget:
                self.control.addDockWidget(q_dock_area, widget)
                widget.show()
    elif isinstance(layout, Tabbed):
        active_widget = first_widget = None
        for item in layout.items:
            widget = self._prepare_toplevel_for_item(item)
            if (not widget):
                continue
            if (item.id == layout.active_tab):
                active_widget = widget
            if first_widget:
                self.control.tabifyDockWidget(i, widget)
            else:
                if (not _toplevel_added):
                    self.control.addDockWidget(q_dock_area, widget)
                first_widget = widget
            widget.show()
        if (not active_widget):
            active_widget = first_widget
        if active_widget:
            QtCore.QTimer.singleShot(0, active_widget.raise_)
    elif isinstance(layout, Splitter):
        orient = ORIENTATION_MAP[layout.orientation]
        prev_widget = None
        for item in layout.items:
            widget = self._prepare_toplevel_for_item(item)
            if (not widget):
                continue
            if prev_widget:
                self.control.splitDockWidget(prev_widget, widget, orient)
            elif (not _toplevel_added):
                self.control.addDockWidget(q_dock_area, widget)
            prev_widget = widget
            widget.show()
        for (i, item) in enumerate(layout.items):
            self.set_layout_for_area(item, q_dock_area, _toplevel_added=True, _toplevel_call=False)
    else:
        raise MainWindowLayoutError(('Unknown layout item %r' % layout))
    if _toplevel_call:
        QtCore.QTimer.singleShot(0, self._reset_fixed_sizes)

dataset/ETHPy150Open enthought/pyface/pyface/ui/qt4/tasks/main_window_layout.py MainWindowLayout.set_layout_for_area/VarMisuse@150/228 `first_widget`->`i`