Here is the issue. Disregarding my inital question for now regarding passing the path, I just filled in the path for function loadExcelData 'C:\Query1.xlsx' directly. The issue is I can only get Query1.xlsx to load into QtableWidget using the first method which involves calling the function directly. When I try event/callback I get the following error
CALL DEF DIRECTLY-works
class Ui_MainWindow(QtWidgets.QMainWindow):
" "
" "
self.treeView.clicked.connect(
lambda _, xl_path=excel_file_path, sheet_name=worksheet_name:
self.loadExcelData(xl_path, sheet_name))
EVENT/CALLBACK-this doesn't work
I get "Process finished with exit code -1073740791 (0xC0000409)"
class Ui_MainWindow(QtWidgets.QMainWindow):
" "
" "
self.treeView.clicked.connect(self.test)
def test(self, signal):
loadExcelData(self, file_path)
def loadExcelData(self, xl_path, worksheet_name):
df = pd.read_excel('C:\Query1.xlsx')
" "
Do I need a pyqt slot?
The easiest way is just to create an event/callback function that's connected to your treeView's "clicked" signal/trigger and call your "loadExcelData" and any other logic from the connected function:
self.treeView.clicked.connect(this.viewClicked)
def viewClicked(self):
self.loadExcelData(self.model.filepath, sheet_name)