我刚开始使用tkinter而且我遇到了一个问题,下面代码中的标签应该显示一个相当长的数字(0.7522488614550792)但不幸的是它没有,唯一可见的是一点点标签的框架(即使我放大窗口),代码没有给我任何错误,所以我不知道我做错了什么。感谢您的帮助
标签:
label = Label(root, textvariable=extentIndex, relief=RAISED)
label.pack()
整个代码:
def select_image():
global panelA, panelB, panelC
path = filedialog.askopenfilename()
[...]
if panelA is None or panelB is None or panelC is None:
# the first panel will store our original image
panelA = Label(image=original)
panelA.image = original
panelA.pack(side="top", padx=10, pady=10)
# while the second panel will store the edge map
panelB = Label(image=binary)
panelB.image = binary
panelB.pack(side="right", padx=10, pady=10)
panelC = Label(image=ROI)
panelC.image = ROI
panelC.pack(side="left", padx=10, pady=10)
###THIS IS THE LABEL###
**label = Label(root, textvariable=extentIndex, relief=RAISED)
label.pack()**
# otherwise, update the image panels
else:
# update the pannels
panelA.configure(image=original)
panelB.configure(image=binary)
panelC.configure(image=ROI)
panelA.image = original
panelB.image = binary
panelC.image = ROI
# initialize the window toolkit along with the two image panels
root = Tk()
panelA = None
panelB = None
panelC = None
btn = Button(root, text="Select an image", command=select_image)
btn.pack(side="bottom", fill="both", expand="yes", padx="10", pady="10")
root.mainloop()
答案 0 :(得分:0)
发现问题,一旦我将“textvariable”更改为“text”,它就开始工作了,所以来自:
label = Label(root, textvariable=extentIndex, relief=RAISED)
到
label = Label(root, text=extentIndex)
tutorialspoint可能有一个过时的公式