code: def _create_dock(self):
          
          # Import dock here as it needs to be imported AFTER i18n is set up
          from safe.gui.widgets.dock import Dock
          self.dock_widget = Dock(self.iface)
          self.dock_widget.setObjectName('InaSAFE-Dock')
          self.iface.addDockWidget(Qt.RightDockWidgetArea, self.dock_widget)
          legend_tab = self.iface.mainWindow().findChild(QApplication, 'Legend')
          if legend_tab:
              self.iface.mainWindow().tabifyDockWidget(
                  legend_tab, self.dock_widget)
              self.dock_widget.raise_()
docs: Create dockwidget and tabify it with the legend.