I don't know exactly where my problem lies, it is either in the bindings, or its the function being called itself.
My buttons all appear under a labelFrame and each are accompanied with an entry box, so that many csv files can be loaded by the user for analysis, and the filepaths are visible. It has to be searched by the user as these files can existed in my different and unconnected project folders.
This is an example button.
csv_type21 = Button(csvfiles, text = "Browse ...")
csv_type21.bind("<Button-1>", lambda event, obj = var21, tid = 21: find_cvsfile(event, obj, tid))
They remain sunken if the user cancels looking for the file, and even if they choose a file it stays sunken. (but the entry box does get updated with the filepath).
This is the function they call, it asks for a csv file and saves it as a tuple, so that I can keep track of which csv is which. After that I set the StringVar for the Entry box that the button is in line with to state the filepath.
def find_csvfile(event, obj, tid):
input_csvfile = askopenfile(initialdir = 'C:/',
filetypes = [("CSV File", "*.csv")],
title = 'Open CSV File for id ' + str(tid) + '...',
mode = 'r')
csv_data = tid, input_csvfile
filepath = input_csvfile.name
obj.set(filepath)
I've tried fiddling loads of different variables and arguments but nothing works. I think it has to be the multiple buttons calling the same command but I can't be sure.
Any help is appreciated.
Thanks.