Tcl Tk窗口布局,小部件大小最大化

Tcl Tk窗口布局,小部件大小最大化,tcl,tk,Tcl,Tk,我正在尝试使用TK包在tcl中创建一个窗口 该窗口由4个文本小部件和一个菜单栏组成 (像这样:) 但我想让窗户最大限度地靠近屏幕 我试图通过以下方式做到这一点: 设置宽度小[expr{int([winfo screenwidth.]*0.25}] text.main\ -宽度$宽度小-高度$高度大\ 但这样做的结果是窗口比屏幕更宽 这怎么可能 proc buildUI {} { global widthsmall global widthbig global he

我正在尝试使用TK包在tcl中创建一个窗口

该窗口由4个文本小部件和一个菜单栏组成

(像这样:)

但我想让窗户最大限度地靠近屏幕

我试图通过以下方式做到这一点:


设置宽度小[expr{int([winfo screenwidth.]*0.25}]

text.main\
-宽度$宽度小-高度$高度大\

但这样做的结果是窗口比屏幕更宽

这怎么可能

proc buildUI {} {
    global widthsmall
    global widthbig
    global heightsmall
    global heightbig
    frame .toolbar
    scrollbar .vsb -command [list .main yview]
    text .main \
        -width $widthsmall -height $heightbig \
        -yscrollcommand [list .vsb set] \
        -highlightthickness 0
   scrollbar .vsb1 -command [list .test yview]
    text .test \
        -width $widthbig -height $heightbig \
        -yscrollcommand [list .vsb1 set] \
        -highlightthickness 0

    scrollbar .vsb2 -command [list .tsvf yview]
    text .tsvf \
        -width $widthsmall -height $heightsmall \
        -yscrollcommand [list .vsb2 set] \
        -highlightthickness 0

    scrollbar .vsb3 -command [list .tobsw yview]
    text .tobsw \
        -width $widthbig -height $heightsmall \
        -yscrollcommand [list .vsb3 set] \
        -highlightthickness 0

    button .b -text start -command start_sim
    pack .b -in .toolbar -side left

    grid .toolbar -sticky nsew -column 0 -row 0 -columnspan 2
    grid .main .vsb  -sticky nsew -column 0 -row 1
    grid .test .vsb1  -sticky nsew -column 1 -row 1
    grid .tsvf .vsb2  -sticky nsew -column 0 -row 2
    grid .tobsw .vsb3 -sticky nsew -column 1 -row 2
} 

要最大化名称在变量
win
中的窗口,请使用

wm state $win zoomed
在Windows和Mac OS X上,或

wm attributes $win -zoomed 1
在X11系统上

要使窗口内的小部件展开以匹配窗口的增大大小,请配置几何体管理器以进行展开

pack .mywidget -expand 1 -fill both ;# grow in both x and y
pack .mywidget -expand 1 -fill x    ;# grow in x
pack .mywidget -expand 1 -fill y    ;# grow in y

grid rowconfigure    . .mywidget -weight 1 ;# this row will expand
grid columnconfigure . .mywidget -weight 1 ;# this column will expand

文档:,

您的问题缺少代码,我们很难猜到。如何将其打包或网格化?窗口中的文本字段高度和宽度将绕过该选项call@user1104939:文本小部件将不参与此操作。使用此调用可以最大化正在使用的主窗口(
)或顶级窗口。你可以让geometry manager在最大化的窗口中设置小部件的大小,也可以自己设置这些大小。但是它仍然不能解决文本小部件不能随窗口调整大小的问题。我希望左侧的两个小部件(如您在原始帖子中看到的)始终是窗口的1/4。@user1104939:请参阅更新的答案。你要的是这样的东西吗?