无法在tcl/tk中移动按钮

无法在tcl/tk中移动按钮,tcl,tk,Tcl,Tk,在这段代码中,我想将new_按钮移到最右边。但在更改行、列、列span之后,它只会停留在那里。代码中需要做哪些更改 ttk::frame .c .c configure -borderwidth 7 -relief groove -padding "200 25" button .c.cancle -text cancel -command {destroy .} ttk::label .c.l -text "yash" ttk::checkbutton .c.one -text One -va

在这段代码中,我想将new_按钮移到最右边。但在更改行、列、列span之后,它只会停留在那里。代码中需要做哪些更改

ttk::frame .c
.c configure -borderwidth 7 -relief groove -padding "200 25"
button .c.cancle -text cancel -command {destroy .}
ttk::label .c.l -text "yash"
ttk::checkbutton .c.one -text One -variable oe -onvalue 1
ttk::button .c.ok -text Okay -command sp12
button .c.lop -text New_button

grid .c -column 0 -row 4
grid .c.l -column 0 -row 1 -columnspan 2
grid .c.one -column 0 -row 3 -columnspan 2
grid .c.ok -column 3 -row 3 -columnspan 2
grid .c.cancle -column 9 -row 3 -columnspan 2
grid .c.lop -column 30 -row 10 -rowspan 10 -columnspan 15 -sticky w
网格可能很棘手。如果其中一行或列中没有小部件,则该行和/或列将被视为具有0宽度和/或0高度。因此,增加行号和/或列号不会改变任何事情

在当前脚本中,对框架的填充可以防止.c网格中的小部件靠近.c边框填充在边框和其中的小部件之间添加一层空间。所以这是第一件要移除的东西。一旦完成,小部件将丢失其大小,因为小部件的大小毕竟取决于其内部小部件的大小

因此,这里的解决方法是定义最小尺寸:

ttk::frame .c
.c configure -borderwidth 7 -relief groove
wm minsize . 656 135  # Set a minimum size here
button .c.cancle -text cancel -command {destroy .}
ttk::label .c.l -text "yash"
ttk::checkbutton .c.one -text One -variable oe -onvalue 1
ttk::button .c.ok -text Okay -command sp12
button .c.lop -text New_button

# I cleaned up the columns
grid .c -row 0 -column 0 -sticky nsew # make it anchor all positions
grid .c.l -column 1 -row 1
grid .c.one -column 1 -row 2
grid .c.ok -column 2 -row 2
grid .c.cancle -column 3 -row 2
grid .c.lop -column 4 -row 3 -sticky se # make it anchor at south east position

# make the .c grid fit to the . window
grid columnconfigure . all -minsize 635 -weight 1
grid rowconfigure . all -weight 1
# force column before column 1 and row before row 1 to have some specific size
grid columnconfigure .c 0 -minsize 200
grid rowconfigure .c 0 -minsize 30
# make the last cell fill any spaces after it, if available
grid columnconfigure .c 4 -weight 1
grid rowconfigure .c 4 -weight 1
结果:


你想创建什么布局?我已经运行了你的代码,但我不太确定它应该是什么样子…删除框架上的填充。c.是的@Jerry,但它减少了窗口大小…我如何才能获得更大的框架窗口…例如,如果我给第30列按钮,它应该远离第9列按钮。@Yash你能上传一张你想要得到的结果的图片吗?用油漆或其他东西画出来,但是如果没有更多的信息,你很难理解你在找什么。@Jerry上传。。如果你无法访问,请告诉我