code: def create_toggle_view_action(self):
          
          title = self.get_plugin_title()
          if self.CONF_SECTION == 'editor':
              title = _('Editor')
          if self.shortcut is not None:
              action = create_action(self, title,
                               toggled=lambda checked: self.toggle_view(checked),
                               shortcut=QKeySequence(self.shortcut),
                               context=Qt.WidgetShortcut)
          else:
              action = create_action(self, title, toggled=lambda checked:
                                                  self.toggle_view(checked))
          self.toggle_view_action = action
docs: Associate a toggle view action with each plugin