def doubleck(self): critem = self.listWidget.currentItem() reply = QMessageBox.question(self.centralwidget, '删除', '确认删除吗?', QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if reply == QMessageBox.Yes: self.listWidget.takeItem(self.listWidget.currentRow()) del self.data[critem.text()] myjson.write('./data.json', self.data)
def addtolist(self): ## 添加到列表自动获取图片 # closeproxy(self) text = self.lineEdit.text() if text not in self.mylist and text != "": self.data[text] = {"title": "未命名", "pic": []} self.mylist = list(self.data.keys()) self.listWidget.clear() self.renderlist(self.mylist) myjson.write('./data.json', self.data) self.cacheimg()
def doubleck(self): crrow = self.listWidget.currentRow() critem = self.mylist[crrow] reply = QMessageBox.question(self.centralwidget, '删除', '确认删除吗?', QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) if reply == QMessageBox.Yes: self.listWidget.takeItem(self.listWidget.currentRow()) del self.data[critem] self.mylist = list(self.data.keys()) self.listWidget.clear() self.renderlist(self.mylist) myjson.write('./data.json', self.data)
def addtolist(self): ## 添加到列表自动获取图片 # closeproxy(self) text = self.lineEdit.text() if text not in self.mylist and text != "": item = QListWidgetItem(text) # item.setSizeHint(QSize(50,50)) # layout_right_down = QHBoxLayout() # 右下的横向布局 # layout_right_down.addWidget(QLabel(text)) # layout_right_down.addWidget(QLabel("label")) # wg= QWidget() # wg.setLayout(layout_right_down) # self.listWidget.setItemWidget(item, wg) self.listWidget.addItem(item) # 创建本地缓存 载入时加载本地缓存! self.data[text] = [] self.mylist = list(self.data.keys()) myjson.write('./data.json', self.data) self.cacheimg()
def savechange(self): print("字段保存") for index, i in enumerate(self.mylist): title = globals()['Qline_' + str(index)].text() self.data[i] = {"title": title, "pic": self.data[i]['pic']} myjson.write('./data.json', self.data)