So I have something like this:
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
import pandas as pd
window = tk.Tk()
window.geometry('350x240')
def open_file():
temp_file = filedialog.askopenfilename(title="Open file", filetypes=[("Excel files", "*.csv")])
temp_file = open(temp_file, "r")
Proj_df = pd.read_csv(temp_file)
open_button = ttk.Button(text='Select File...', command=open_file)
open_button.grid(column=1, row=1)
def get_info():
x = open_button.get()
print (x)
button1 = ttk.Button(text='Get Information', command=get_info)
button1.grid(column=0, row=2)
What I'm trying to do is to store the DataFrame created in open_file() to use it in get_info(). I'm getting:
AttributeError: 'Button' object has no attribute 'get'
How could I access the DataFrame created in open_button?
global, there is really no way to retrieve values from functions that are called by aButtonfrom thatButton(I mean it is not impossible to create a button that would be able to do this, but it is much easier to just useglobal(or OOP))