class MainWindow(QWidget): def __init__(self): super(MainWindow, self).__init__() # Importing data from Qt UI file uic.loadUi("pathSelection.ui", self) self.nameBrowse1.clicked.connect(self.browseFiles1) self.nameBrowse2.clicked.connect(self.browseFiles2) if self.fileName1 == self.fileName2: print("Both files are same") else: print("Both files are different") def browseFiles1(self): fname1 = QtWidgets.QFileDialog.getExistingDirectory( None, 'Select folder:', './img', QtWidgets.QFileDialog.ShowDirsOnly ) if fname1: self.fileName1.setText(fname1) def browseFiles2(self): fname2 = QtWidgets.QFileDialog.getExistingDirectory( None, 'Select folder:', './img', QtWidgets.QFileDialog.ShowDirsOnly ) if fname2: self.fileName2.setText(fname2)
In this code, I am trying to make the if-statement work. I am browsing two folders and I want that if a user selects two same folders location, then the message should appear in the terminal that both files are the same, and if not then the message should be the opposite. But when I run the code, the else statement appears in the terminal. Although I didn't select any file. But if I browse files then it does not give me any message.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)