P
P
Pavel2022-04-03 07:18:13
PyQt
Pavel, 2022-04-03 07:18:13

Why is False coming?

Good time! On pyqt5 there is a simple form with a button and openfiledialog, I can’t understand why False arrives when passing an argument from the open_file_1 function to the main function

class MainWindow(QMainWindow):

    def __init__(self):
        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Вешаем обработчики на кнопки
        self.ui.open_btn_1.clicked.connect(self.open_file_1)
        self.ui.open_btn_2.clicked.connect(self.open_file_2)
        self.ui.run.clicked.connect(self.main)
    def open_file_1(self):
        file1 = QFileDialog.getOpenFileName(self, 'Open file', './', 'Image File (*.jpg)', path)[0]
        file_name_1 = file1.split('/')[-1]
        self.ui.lineEdit.setText(file1)
        return file_name_1

    def main(self, file_name_1):
        print(file_name_1)
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    myapp = MainWindow()
    myapp.show()
    sys.exit(app.exec_())


Please write to the point!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question