How can i access to an array returned by other function?

I have this function to open two arrays of a txt file and create a table and an #embedded graph in root. The problem is that i cannot access the matrix returned by this function in order to use it in a different function:

def open_txt2():
    text_file=filedialog.askopenfilename(initialdir="C:/Macintosh HD/Utilizadores/Python/Visuall Studio/", title="Open text file", filetypes=(("Text Files", "*.txt"),))

    data=np.loadtxt(text_file)
    Psi=data[:,0]
    Del=data[:,1]

    fig=plt.figure()  
    plt.plot(Psi,Del,'bo', markersize=3)
    plt.ylabel(u'\u0394 /°')
    plt.xlabel(u'\u03A8 /°')
    plt.legend(['Experimental'])  

    PlotFrame=tk.Frame(f23, width=500, height=300)
    PlotFrame.grid(row=0, column=1)
    canvas = FigureCanvasTkAgg(fig, master=PlotFrame)  # A tk.DrawingArea.
    canvas.draw()
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
    toolbar = NavigationToolbar2Tk(canvas, PlotFrame)
    toolbar.update()
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)



    datatable=np.column_stack((Psi,Del))
    dataset = pd.DataFrame({'Psi': datatable[:, 0], 'Del': datatable[:, 1]})
    table=Table(f21b,column=0,dataframe=dataset, width=200, sticky='w')
    table.show()
    return datatable

I just can access it if i open in main window like this:

a=open_txt2()
PSIe=a[:,0]
DELe=a[:,1]

Thank you!

What happens if you have on function to load the data and another one to display it? Something like

def open_txt2():
    text_file=filedialog.askopenfilename(initialdir="C:/Macintosh HD/Utilizadores/Python/Visuall Studio/", title="Open text file", filetypes=(("Text Files", "*.txt"),))

    data=np.loadtxt(text_file)
    Psi=data[:,0]
    Del=data[:,1]

    datatable=np.column_stack((Psi,Del))
    return datatable

And then another function like

def show_matrix(datatable):
    fig=plt.figure()  
    plt.plot(Psi,Del,'bo', markersize=3)
    plt.ylabel(u'\u0394 /°')
    plt.xlabel(u'\u03A8 /°')
    plt.legend(['Experimental'])  

    PlotFrame=tk.Frame(f23, width=500, height=300)
    PlotFrame.grid(row=0, column=1)
    canvas = FigureCanvasTkAgg(fig, master=PlotFrame)  # A tk.DrawingArea.
    canvas.draw()
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
    toolbar = NavigationToolbar2Tk(canvas, PlotFrame)
    toolbar.update()
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)

    dataset = pd.DataFrame({'Psi': datatable[:, 0], 'Del': datatable[:, 1]})
    table=Table(f21b,column=0,dataframe=dataset, width=200, sticky='w')
    table.show()

And then pass it like

a = open_txt2()
show_matrix(a)

Would this work?

I want to open an array with a button an d the i want to have this array available to be used in other function. With this :
a = open_txt2()
show_matrix(a)

It will initialize the opening of txt when start the program and i want to do it with a button. Thanks for your time!

I want to open a txt file and generate an array with a button command and then i need this array for a different function

Would something like this work?

And your openfile function would be open_txt2

Yes. And the use the array from the txt file in a different function

Yes. And then need to use the array from the txt file in a different function