如果未提供网格的行参数会发生什么?

huangapple go评论64阅读模式
英文:

What happens, if the row parameter of the grid is not supplied?

问题

如果将行参数留空(例如 frame.grid(column=0, pady=5) ),它会将此框架添加到最后一个已占用的行之后。这在我的程序中是有效的。但后来我决定阅读tcl.tk手册,其中有一句话我不太理解:“如果未提供此选项,则内容将与在此调用grid时指定的先前内容排列在同一行上,或者如果这是第一个内容,则在最高已占用行之后的下一行”。我不太理解,在什么情况下会将内容放在同一行上,什么情况下会放在不同的行上。也许有人可以用不同的话重新表述一下,因为我真的不太明白他们的意思。

英文:

I thought, that in the case, if you put you row parameter empty (e.g. frame.grid(column=0, pady=5)) it will add this frame after the last occupied row. And it did that in my program. But then I decided to read about this in tcl.tk man doc, and there is a sentence that I can't understand: "If this option is not supplied, then the content is arranged on the same row as the previous content specified on this call to grid, or the next row after the highest occupied row if this is the first content". I can't understand, in what case it will put the content on the same row, in what on the different. Maybe someone could rephrase this in a different words, because can't really understand what did they mean

答案1

得分: 0

使用tcl时,您可以使用单个grid调用来排列同一行上的多个小部件。在tkinter中,当您调用grid方法时,您每次只能在一个小部件上使用它。

因此,在tcl中,您可以像下面这样做,将.foo放在第1行,然后将.bar.baz放在第2行,因为第二行没有指定行:

grid .foo -row 1
grid .bar .baz

在tkinter中,您每次只能在一个小部件上调用grid,这意味着未指定的行将始终是下一个未使用的行。

换句话说,每次调用grid时,该单个grid调用中的所有小部件都将位于同一行 - 要么指定的行,要么下一行。在tcl中,您可以一次传递多个小部件,但在tkinter中,您始终只能指定一个小部件。

英文:

When using tcl, you can use a single call to grid to arrange multiple widgets on the same row. In tkinter, when you call the grid method you can only use it on one widget at a time.

So, in tcl you can do something like the following, which will put .foo on row 1, and then .bar and .baz on row 2 since the row is not specified on the second line.

grid .foo -row 1
grid .bar .baz

In tkinter you can only call grid on one widget at a time, which means that an unspecified row will always be the next unused row.

Put another way, every time you call grid, all widgets in that single call to grid will be on the same row - either the specified row or the next row. In tcl you can pass multiple widgets at once, but in tkinter you can always only specify a single widget.

huangapple
  • 本文由 发表于 2023年7月23日 20:42:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76748303.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定