예제 #1
1
    def __init__(self):
        QtGui.QDialog.__init__(self)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.setFixedSize(self.width(), self.height())

        self._data = readData()
        self._findData = []

        self.ui.pushButton_search.clicked.connect(self.onSearchClick)
        self.ui.pushButton_export.clicked.connect(self.onExportClick)
        self.ui.listWidget.itemDoubleClicked.connect(self.onItemDoubleClick)
        pass
예제 #2
1
class Dialog(QtGui.QDialog):

    def __init__(self):
        QtGui.QDialog.__init__(self)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.setFixedSize(self.width(), self.height())

        self._data = readData()
        self._findData = []

        self.ui.pushButton_search.clicked.connect(self.onSearchClick)
        self.ui.pushButton_export.clicked.connect(self.onExportClick)
        self.ui.listWidget.itemDoubleClicked.connect(self.onItemDoubleClick)
        pass

    def onSearchClick(self):

        strKey = self.ui.lineEdit.text().strip()
        isOr = self.ui.checkBox.isChecked()

        self._findData = findItem(self._data, strKey, isOr)
        self.updateListView()

        pass

    def onExportClick(self):
        filename = QtGui.QFileDialog.getSaveFileName(self, '导出链接', str(datetime.datetime.now()) + '.txt', '*.txt')
        if len(filename) > 0:
            with open(filename, 'w+') as writer:
                for item in self._findData:
                    writer.write(item.url + '\n')
                    pass
                pass
            pass
        pass

    def onItemDoubleClick(self, item):
        targetKey = item.text()
        targetValue = ''
        for item in self._data:
            if targetKey == item.book:
                targetValue = item.url
                break
                pass
            pass
        print(targetValue)
        QtGui.QMessageBox.information(self, '链接', targetValue)

        pass

    def updateListView(self):
        self.ui.listWidget.clear()
        strList = []

        for item in self._findData:
            strList.append(item.book)
            pass

        self.ui.listWidget.addItems(strList)

        pass
    pass