Quantcast
Viewing latest article 12
Browse Latest Browse All 32

Passing data from one fucntion to another. Python

I am working on an app and I have made a UI with the qt5 creator. I have a function bound to a button.

self.dataChooseBtn.clicked.connect(self.selectFile)self.data_processing.clicked.connect(self.process)def selectFile(self):        options = QFileDialog.Options()    options |= QFileDialog.DontUseNativeDialog    fileName, _ = QFileDialog.getOpenFileName(self,"Выберитестандартизированнуювыборку", "","All Files (*);;Python Files (*.py)", options=options)    if fileName:        print(fileName)        return fileName

When pressing this button, I get a dialog window, where I can choose a file.

Also, I have a function, that should process the chosen file. Right now, the path to file and its name are hardcoded.

def process(self):    file_location = "/Users/Graygood/Desktop/Science\ comput/Application/Sheet.xlsx"    sample = pd.read_excel('Sheet.xlsx', sheetname ='Sheet1', index_col=None, na_values=['NA'])

What I want, is to get the output of a selectFile() function (triggered by the click) (for example: /Users/Graygood/Desktop/Science comput/Application/Sheet.xlsx) and insert it into process() function (also triggered by the click), without triggering the dialog window again. Which happens if I just call selectFile() function in process() one.

def process(self):    fileName = self.selectFile()    file_location = fileName    sample = pd.read_excel('Sheet.xlsx', sheetname ='Sheet1', index_col=None, na_values=['NA'])

Viewing latest article 12
Browse Latest Browse All 32

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>