-1

看来我把我的问题解释得很糟糕,但是我标签上的网格功能有问题。标签确实显示了,但是我无法更改它的行/列或在括号内执行任何功能。

我把如何复制问题的代码放在那里。如前所述,将任何内容放在 .grid() 括号内都不会做任何事情

from tkinter import *
root = Tk()

#To actually see that it does not work
root.geometry("800x600")

Var = StringVar()

Label = Label(root, textvariable=Var)

#Location of problem, adding stuff into the brackets does not change anything. For example: sticky = "ne"
Label.grid()

Var.set("Ha")

root.mainloop()
4

1 回答 1

0

要使标签显示在右侧,您可以指定网格中的列数,然后将标签放在最后一列中。例如,尝试在您的“#Location of problem”评论之后添加这个:

cols = 0
while cols < 4:
    root.columnconfigure(cols, weight=1)
    cols += 1
Label.grid(column=3)
于 2018-08-20T17:43:03.470 回答