我有一个列表结果。我正在尝试使用tkinter在标签窗口小部件中显示结果的内容。仅第一个条目不显示其他任何内容。我尝试调试,看起来循环遍历了列表的整个长度,但未显示小部件。
for i in range(0, len(result.deviceName)):
position = 0.582 + (i * 0.5)
print(result.deviceName[i])
self.TLabel2_12 = ttk.Label(self.reportWindow)
self.TLabel2_12.place(
relx=0.044, rely=position, height=29, width=186)
self.TLabel2_12.configure(text=result.deviceName[i])
self.TButton1 = ttk.Button(
self.reportWindow, command=lambda i=i: self.displayRoutes(i))
self.TButton1.place(relx=0.366, rely=position,
height=25, width=136)
self.TButton1.configure(takefocus="")
self.TButton1.configure(text='''VIEW ROUTES''')
self.TButton1.configure(width=136)
if(result.check[i] == 1):
self.TLabel2_12 = ttk.Label(self.reportWindow)
self.TLabel2_12.place(
relx=0.198, rely=position, height=29, width=196)
self.TLabel2_12.configure(text='''CORRECT''')
else:
self.TLabel2_12 = ttk.Label(self.reportWindow)
self.TLabel2_12.place(
relx=0.198, rely=position, height=29, width=196)
self.TLabel2_12.configure(text='''INCORRECT''')
self.TButton1_13 = ttk.Button(
self.reportWindow, command=lambda i=i: self.displayError(i))
self.TButton1_13.place(
relx=0.512, rely=position, height=25, width=136)
self.TButton1_13.configure(text='''ERROR''')
答案 0 :(得分:0)
您需要
self.reportWindow.update()
循环末尾的更新主根。这显示了所有小部件。