Python 在列表框中插入“不工作”
所以我已经尝试了好几个小时,我的代码应该在全局变量glob等于1时向这个列表框中插入一个字符串,我在没有if语句的情况下尝试过,它确实插入了字符串。我是不是遗漏了什么? 谢谢Python 在列表框中插入“不工作”,python,if-statement,listbox,Python,If Statement,Listbox,所以我已经尝试了好几个小时,我的代码应该在全局变量glob等于1时向这个列表框中插入一个字符串,我在没有if语句的情况下尝试过,它确实插入了字符串。我是不是遗漏了什么? 谢谢 这似乎不是一个最小的完全可行的例子——瞧,没有足够的信息来回答这个问题。(请参阅)确保您的代码正在输入else块,在else子句中添加print语句。 def open_file(self): """ Function in charge of opening a chosen file with a
这似乎不是一个最小的完全可行的例子——瞧,没有足够的信息来回答这个问题。(请参阅)确保您的代码正在输入
else
块,在else
子句中添加print
语句。
def open_file(self):
"""
Function in charge of opening a chosen file with a
filedialog
"""
filename = filedialog.askopenfilename()
base = os.path.basename(filename)
name = base.replace(".csv", "")
if not base.endswith('.csv'):
print('Wrong archive')
else:
a = AnimalData()
td=a.load_data(filename)
global glob
glob +=1
tv.append(a.to_tabbed_string(order[name]-1))
class SelectionBox(tk.Listbox):
def __init__(self, master):
super().__init__(master, bg='white',relief = tk.RAISED
if glob == 1:
self.insert(0, tv[glob-1])