I need to change a Tkinter label from inside a function but it isn't passing through correctly because I get the error
(我需要从函数内部更改Tkinter标签,但它无法正确传递,因为出现错误)
AttributeError: 'NoneType' object has no attribute 'config'
(AttributeError:“ NoneType”对象没有属性“ 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)
ask by Jack Ashford translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…