code: def setup_menu(self):
          
          copy_action = create_action(self, _('Copy'),
                                      shortcut=keybinding('Copy'),
                                      icon=ima.icon('editcopy'),
                                      triggered=self.copy,
                                      context=Qt.WidgetShortcut)
          functions = ((_("To bool"), bool), (_("To complex"), complex),
                       (_("To int"), int), (_("To float"), float),
                       (_("To str"), to_text_string))
          types_in_menu = [copy_action]
          for name, func in functions:
              slot = lambda func=func: self.change_type(func)
              types_in_menu += [create_action(self, name,
                                              triggered=slot,
                                              context=Qt.WidgetShortcut)]
          menu = QMenu(self)
          add_actions(menu, types_in_menu)
          return menu
docs: Setup context menu.