I need to change a Tkinter label from inside a function but it isn't passing through correctly because I get the error
AttributeError: 'NoneType' object has no attribute 'config'
My code is
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio import SeqIO
from tkinter import *
from tkinter import ttk, filedialog
import os
def select_file(fileLabel):
filename = filedialog.askopenfilename(initialdir=".")
name, extension = os.path.splitext(filename)
extension=''.join(extension.split('.', 1))
for seq_record in SeqIO.parse(filename, extension):
sequence = seq_record.seq
fileBase=os.path.basename(os.path.normpath(filename))
fileLabel.config(text=fileBase)
tk = Tk()
fileLabel = ttk.Label(text = "No File Selected").pack()
ttk.Button(text = "Select FASTA/Genbank",command = lambda: select_file(fileLabel)).pack()
tk.mainloop()
Does anyone know what I'm doing wrong?
Edit: The error is on the line
fileLabel.config(text=fileBase)