Endnote半自动导入小软件

endnote半自动导入小软件,可以实现文献的半自动导入

from PyQt5.QtWidgets import QWidget, QPushButton, QLabel, QApplication, QVBoxLayout, QFileDialog, QMessageBox
import sys
import os
import pyperclip

class xia(QWidget):
    def __init__(self):
        super().__init__()
        self.PushB1 = QPushButton("选择路径")
        self.PushB2 = QPushButton("复制文件名称")
        self.PushB3 = QPushButton("复制绝对路径")
        self.PushB4 = QPushButton("下一个")
        self.Label1 = QLabel("当前顺序")
        self.files = []
        self.Num = 0
        self.src = ""
        self.fileName = ""

        layout = QVBoxLayout()
        layout.addWidget(self.PushB1)
        layout.addWidget(self.PushB2)
        layout.addWidget(self.PushB3)
        layout.addWidget(self.PushB4)
        layout.addWidget(self.Label1)
        self.setLayout(layout)
        self.resize(800, 200)
        self.setWindowTitle("Endnote手动导入软件")

        self.PushB1.clicked.connect(self.path_choose)
        self.PushB2.clicked.connect(self.fileName_Copy)
        self.PushB3.clicked.connect(self.abs_path_Copy)
        self.PushB4.clicked.connect(self.next_file)
        self.Label1.setText(str(self.Num))

    def path_choose(self):
        a = QFileDialog.getExistingDirectory()
        self.files = os.listdir(a)
        self.src = a

    def fileName_Copy(self):
        os.chdir(self.src)
        file_name = self.files[self.Num]
        self.fileName = file_name
        file_name = os.path.splitext(file_name)[0]
        pyperclip.copy(file_name)
        print(self.fileName)

    def abs_path_Copy(self):
        src=self.src
        src=src.replace('/','\\')
        pyperclip.copy(os.path.join(src, self.fileName))
        print(os.path.join(self.src, self.fileName))

    def next_file(self):
        if self.Num < len(self.files):
            self.Num = self.Num + 1
            self.fileName_Copy()
            self.Label1.setText(str(self.Num))
        else:
            QMessageBox.about(self, "状态", "已经完毕!")


if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = xia()
    win.show()
    sys.exit(app.exec_())

你可能感兴趣的:(Endnote半自动导入小软件)