code: def switch_to_plugin(self):
          
          # Unmaxizime currently maximized plugin
          if (self.main.last_plugin is not None and
                  self.main.last_plugin.ismaximized and
                  self.main.last_plugin is not self):
              self.main.maximize_dockwidget()
  
          # Show plugin only if it was already visible
          if self.get_option('visible_if_project_open'):
              if not self.toggle_view_action.isChecked():
                  self.toggle_view_action.setChecked(True)
              self.visibility_changed(True)
docs: Switch to plugin.