0

(This code is just a part of the bigger project) So I want to select a file from file dialog (works fine), the I want to copy and paste it into another folder named 'files'. I checked the documentation of PyQt5 but somehow I can't seem to find a syntax that copies and pastes the selected file to another folder.

class main_Menu(QtWidgets.QWidget):
    global file_save
    def __init__(self):
        super().__init__()
        self.main_init_ui()

    def main_init_ui(self):
        self.dosya_ekle = QtWidgets.QPushButton("Add Document")
        self.dosya_sil = QtWidgets.QPushButton("Delete Document")
        self.get_results = QtWidgets.QPushButton("Get Results")
        self.sign_out = QtWidgets.QPushButton("Sign Out")

        horizontalLayout = QtWidgets.QHBoxLayout()
        verticalLayout = QtWidgets.QVBoxLayout()
        horizontalLayout.addStretch()
        horizontalLayout.addWidget(self.dosya_ekle)
        horizontalLayout.addWidget(self.dosya_sil)
        horizontalLayout.addWidget(self.get_results)
        horizontalLayout.addWidget(self.sign_out)
        horizontalLayout.addStretch()

        verticalLayout.addStretch()
        verticalLayout.addStretch()
        verticalLayout.addLayout(horizontalLayout)
        verticalLayout.addStretch()

        self.sign_out.clicked.connect(self.click_sign_out)

        self.dosya_ekle.clicked.connect(self.add_dosya)

        self.setLayout(verticalLayout)
        self.setWindowTitle("--- Main Menu ---")

    def click_sign_out(self):
        widget.setCurrentIndex(widget.currentIndex()-2)

    def add_dosya(self):
        path = QFileDialog.getOpenFileName(self, 'Open a file')
        if path != ('', ''):
            print(path[0])
        #this is the part where I can't find a solution

0 Answers0