importsysfromPyQt5importQtWidgetsfromPyQt5.QtGuiimport*fromPyQt5.QtCoreimport*fromPyQt5.QtWidgetsimport*classEditInList(QListWidget):def__init__(self):super(EditInList,self).__init__()# click to editself.clicked.connect(self.item_clicked)defitem_clicked(self,modelindex:QModelIndex)->None:self.edited_item=self.currentItem()self.closePersistentEditor(self.edited_item)item=self.item(modelindex.row())self.edited_item=itemself.openPersistentEditor(item)self.editItem(item)defmouseDoubleClickEvent(self,event):# close editforiinrange(self.count()):self.closePersistentEditor(self.item(i))defleaveEvent(self,event):# close editforiinrange(self.count()):self.closePersistentEditor(self.item(i))