'add,remove and edit rules iptables from WIFi-Pumpkin'

def listItemclicked(self, pos):

    item = self.ListRules.selectedItems()
    self.listMenu = QMenu()
    menu = QMenu()
    additem = menu.addAction('Add')
    editem = menu.addAction('Edit')
    removeitem = menu.addAction('Remove    ')
    clearitem = menu.addAction('clear')
    action = menu.exec_(self.ListRules.viewport().mapToGlobal(pos))
    if (action == removeitem):
        if (item != []):
            self.ListRules.takeItem(self.ListRules.currentRow())
    elif (action == additem):
        (text, resp) = QInputDialog.getText(self, 'Add    rules    iptables', 'Enter    the    rules    iptables:')
        if resp:
            try:
                itemsexits = []
                for index in xrange(self.ListRules.count()):
                    itemsexits.append(str(self.ListRules.item(index).text()))
                for i in itemsexits:
                    if search(str(text), i):
                        return QMessageBox.information(self, 'Rules    exist', 'this    rules    already    exist!')
                item = QListWidgetItem()
                item.setText(text)
                item.setSizeHint(QSize(30, 30))
                self.ListRules.addItem(item)
            except Exception as e:
                return QMessageBox.information(self, 'error', str(e))
    elif (action == editem):
        (text, resp) = QInputDialog.getText(self, 'Add    rules    for    iptables', 'Enter    the    rules    iptables:', text=self.ListRules.item(self.ListRules.currentRow()).text())
        if resp:
            try:
                itemsexits = []
                for index in xrange(self.ListRules.count()):
                    itemsexits.append(str(self.ListRules.item(index).text()))
                for i in itemsexits:
                    if search(str(text), i):
                        return QMessageBox.information(self, 'Rules    exist', 'this    rules    already    exist!')
                item = QListWidgetItem()
                item.setText(text)
                item.setSizeHint(QSize(30, 30))
                self.ListRules.insertItem(self.ListRules.currentRow(), item)
            except Exception as e:
                return QMessageBox.information(self, 'error', str(e))
    elif (action == clearitem):
        self.ListRules.clear()
