First of all, I'm a beginner, so any impovement you suggest is really appreciated. Using PyQt5 there is a button which loads up data with np.loadtxt. (It's unpacked into two arrays, because it's x-y data). What I'm trying to achieve is accessing (or storing) that data globally, so later on I can use it in other functions, for example Fourier transform it.
I've already tried to append them into a global np.array defined independently at the top, and also tried the tempfile module, but none of them worked correctly. Here is the function which is called upon clicking the button:
def referenceArmClicked(self):
options = QFileDialog.Options()
referenceName, _ = QFileDialog.getOpenFileName(None,"QFileDialog.getOpenFileName()", "","All Files (*);;Python Files (*.py)", options=options)
try:
if referenceName:
refX, refY= np.loadtxt(referenceName, usecols=(0,1), unpack = True, delimiter =',')
except:
pass #it's just here to simplify the problem, I know it's a bad thing
If I put self.refX
and self.refY
instead of refX
and refY
, I need to pass it to the function as arguments:
def referenceArmClicked(self, self.refX, self.refY)
And this is when I connect the function to the button:
self.iReferenceArm.clicked.connect(self.referenceArmClicked)
.. and it doesn't work, and I'm stuck.
The desired output should look something like this: np.array([refX, refY]) All I've got sor far are empty arrays.