Python Tkinter表,未显示内容
我有一个PythonTkinter代码,主要目的是将多维列表提取到表中。以下是我所拥有的:Python Tkinter表,未显示内容,python,tkinter,Python,Tkinter,我有一个PythonTkinter代码,主要目的是将多维列表提取到表中。以下是我所拥有的: from Tkinter import * def mainApp(Output): RRColor = '#%02x%02x%02x' % (0, 73,144); mGui = Tk(); mGui.title('Relational Table'); mGui.configure(background='grey') text = StringVar();
from Tkinter import *
def mainApp(Output):
RRColor = '#%02x%02x%02x' % (0, 73,144);
mGui = Tk();
mGui.title('Relational Table');
mGui.configure(background='grey')
text = StringVar();
title1 = Label(mGui, text = 'Premise', fg=RRColor, borderwidth=2).grid(row=0, column=0, sticky="nsew", padx=1, pady=1)
title2 = Label(mGui, text = 'Conclusion', fg=RRColor, borderwidth=2).grid(row=0, column=1, sticky="nsew", padx=1, pady=1)
title3 = Label(mGui, text = 'Support', fg=RRColor, borderwidth=2).grid(row=0, column=2, sticky="nsew", padx=1, pady=1)
title4 = Label(mGui, text = 'Confidence', fg=RRColor, borderwidth=2).grid(row=0, column=3, sticky="nsew", padx=1, pady=1)
title5 = Label(mGui, text = 'Lift', fg=RRColor, borderwidth=2).grid(row=0, column=4, sticky="nsew", padx=1, pady=1)
for col in range(len(Output)):
for row in range(len(Output[0])):
text.set(Output[col][row])
content = Label(mGui, textvariable=text, borderwidth=2, fg =RRColor, bg = 'white')
content.grid(row=row+1, column=col, sticky='NSEW', padx=1, pady=1)
mGui.mainloop();
我是从别的地方打来的。我想知道为什么内容没有显示在网格上。我已检查输出是否已成功传递给此。有人能帮我吗?您只使用了一个与循环中创建的每个标签关联的
StringVar
实例。每个小部件都需要自己的StringVar
(“需要”,如“如果您正在使用
StringVar
,则需要为每个标签使用不同的标签”,但严格来说,您根本不需要使用任何StringVar
s)您的代码有缩进错误,因此不可能确切地知道您打算让代码做什么。