'Setup context menu'

def setup_menu(self, minmax):

    if (self.minmax_action is not None):
        self.minmax_action.setChecked(minmax)
        return
    resize_action = create_action(self, _('Resize    rows    to    contents'), triggered=self.resizeRowsToContents)
    self.paste_action = create_action(self, _('Paste'), icon=ima.icon('editpaste'), triggered=self.paste)
    self.copy_action = create_action(self, _('Copy'), icon=ima.icon('editcopy'), triggered=self.copy)
    self.edit_action = create_action(self, _('Edit'), icon=ima.icon('edit'), triggered=self.edit_item)
    self.plot_action = create_action(self, _('Plot'), icon=ima.icon('plot'), triggered=(lambda : self.plot_item('plot')))
    self.plot_action.setVisible(False)
    self.hist_action = create_action(self, _('Histogram'), icon=ima.icon('hist'), triggered=(lambda : self.plot_item('hist')))
    self.hist_action.setVisible(False)
    self.imshow_action = create_action(self, _('Show    image'), icon=ima.icon('imshow'), triggered=self.imshow_item)
    self.imshow_action.setVisible(False)
    self.save_array_action = create_action(self, _('Save    array'), icon=ima.icon('filesave'), triggered=self.save_array)
    self.save_array_action.setVisible(False)
    self.insert_action = create_action(self, _('Insert'), icon=ima.icon('insert'), triggered=self.insert_item)
    self.remove_action = create_action(self, _('Remove'), icon=ima.icon('editdelete'), triggered=self.remove_item)
    self.minmax_action = create_action(self, _('Show    arrays    min/max'), toggled=self.toggle_minmax)
    self.minmax_action.setChecked(minmax)
    self.toggle_minmax(minmax)
    self.rename_action = create_action(self, _('Rename'), icon=ima.icon('rename'), triggered=self.rename_item)
    self.duplicate_action = create_action(self, _('Duplicate'), icon=ima.icon('edit_add'), triggered=self.duplicate_item)
    menu = QMenu(self)
    menu_actions = [self.edit_action, self.plot_action, self.hist_action, self.imshow_action, self.save_array_action, self.insert_action, self.remove_action, self.copy_action, self.paste_action, None, self.rename_action, self.duplicate_action, None, resize_action]
    if (ndarray is not FakeObject):
        menu_actions.append(self.minmax_action)
    add_actions(menu, menu_actions)
    self.empty_ws_menu = QMenu(self)
    add_actions(self.empty_ws_menu, [self.insert_action, self.paste_action, None, resize_action])
    return menu
