I have a getFile function which will get the address of the csv file and print the filename in the command console. When I run the function in the main window, I keep getting "'bool' object has no attribute 'filename'". Why is this happening?
ttreadfile.py
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
def getFile(self):
"""this function will get the address of the sdv file location"""
self.filename = QFileDialog.getOpenFileName(filter = "csv (*.csv)")[0]
print("File:",self.filename)
ttool.py
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from Module.ttreadfile import *
class ApplicationWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
"""set layout of window"""
self.main_widget = QWidget(self)
l = QGridLayout(self.main_widget)
open_button =QPushButton('Open')
open_button.clicked.connect(getFile)
l.addWidget(open_button, 0,0)
if __name__ == '__main__':
app = QApplication(sys.argv)
aw = ApplicationWindow()
aw.setWindowTitle("PyQt5 Matplot Example")
aw.show()
#sys.exit(qApp.exec_())
app.exec_()