首页 > 解决方案 > 无法通过 GRID 在 TCK/TK 中定位我的标签

问题描述

我在 TCL 中设置了一个 TK 屏幕。第一行的标签和第二行的图像按预期正确设置。但是当我想在图像旁边添加一个标签时,它总是在最右边显示它。我什至使用“nw”锚定标签并将框架也粘贴为“nw”,但行为保持不变。有人可以帮忙吗?

package require Tk
package require Img

wm title . "Operator Login"

# Top corner label
ttk::frame .f0
tk::label .f0.l0 -text "Sales Application" -foreground blue \
    -textvariable "Total" -font {Helvetica -18 bold} -anchor ne

# Logo frame
ttk::frame .f1
tk::label .f1.l0 -textvariable "Total" -anchor nw
image create photo imgobj -file "C:/.../.../flowers.bmp"
.f1.l0 configure -image imgobj

# Login frame
ttk::frame .f2
tk::label .f2.l0 -text "ID " -foreground blue -textvariable "ID" \
    -font {Helvetica -13 bold} -anchor nw

# GRID Management
grid .f0 -column 0 -row 0 -columnspan 25 -sticky ne
grid .f0.l0 -column 0 -row 0 -columnspan 25

grid .f1 -column 0 -row 2 -columnspan 4 -rowspan 5 -sticky nsew -pady 5 -padx 5
grid .f1.l0 -column 0 -row 2 -columnspan 4 -rowspan 5 -sticky nsew -pady 5 -padx 5

grid .f2 -column 5 -row 2 -sticky w
grid .f2.l0 -column 5 -row 2

grid columnconfigure . 0 -weight 1
grid columnconfigure .f1 0 -weight 1
grid rowconfigure .f1 0 -weight 1

标签: gridpositiontcltk

解决方案


推荐阅读