code: def add_actions_to_context_menu(self, menu):
          
          inspect_action = create_action(self, _("Inspect current object"),
                                      QKeySequence(get_shortcut('console',
                                                      'inspect current object')),
                                      icon=ima.icon('MessageBoxInformation'),
                                      triggered=self.inspect_object)
  
          clear_line_action = create_action(self, _("Clear line or block"),
                                            QKeySequence(get_shortcut(
                                                    'console',
                                                    'clear line')),
                                            triggered=self.clear_line)
  
          reset_namespace_action = create_action(self, _("Remove all variables"),
                                                 QKeySequence(get_shortcut(
                                                         'ipython_console',
                                                         'reset namespace')),
                                                 icon=ima.icon('editdelete'),
                                                 triggered=self.reset_namespace)
  
          clear_console_action = create_action(self, _("Clear console"),
                                               QKeySequence(get_shortcut('console',
                                                                 'clear shell')),
                                               triggered=self.clear_console)
  
          quit_action = create_action(self, _("&Quit"), icon=ima.icon('exit'),
                                      triggered=self.exit_callback)
  
          add_actions(menu, (None, inspect_action, clear_line_action,
                             clear_console_action, reset_namespace_action,
                             None, quit_action))
          return menu
docs: Add actions to IPython widget context menu