我有一个窗口,里面有小部件。当我手动重新调整窗口大小时,小部件会在高度减小时自行缩放,但在宽度改变或高度放大超过初始高度时不会。如何使小部件堆叠到窗口的边框?
创建窗口的代码:
wm title $base "KitKite Sparam Viewer"
set frm_main [frame $base.main_frm]
pack $frm_main
grid [frame $frm_main.graph ] -row 1 -column 1
set g [sparam_graph_widget $frm_main.graph graph]
grid [set frm [frame $frm_main.frm]] -row 1 -column 2
#from and to frame
set from [frame $frm.from -relief ridge -bd 2]
set from_lbl [label $from.lbl -text "From:"]
set f_tbl_frm [frame $from.tbl_f]
set to [frame $frm.to -relief ridge -bd 2]
set to_lbl [label $to.lbl -text "To:"]
set t_tbl_frm [frame $to.tbl_t]
grid $from -column 1 -row 1 -sticky nwe
grid $from_lbl -row 1 -sticky nsew
grid $f_tbl_frm -row 2 -sticky nsew
grid $to -column 2 -row 1 -sticky nwe
grid $to_lbl -row 1 -sticky nsew
grid $t_tbl_frm -row 2 -sticky nsew
set from_t [sparam_table_widget $f_tbl_frm f_tbl]
set to_t [sparam_table_widget $t_tbl_frm t_tbl]
set data [frame $frm.data]
set data_lbl [label $data.lbl -text "Choose data type to show"]
set isi [checkbutton $data.cb_isi -variable cb(isi) -command [list __sp_data_changed isi $g] -text ISI ]
set xt [checkbutton $data.cb_xt -variable cb(xt) -command [list __sp_data_changed xt $g] -text XT ]
set ref [checkbutton $data.cb_ref -variable cb(ref) -command [list __sp_data_changed ref $g] -text Reflection]
set conf_button [button $data.bt_conf -text "Configure connections" -command [list __sp_configure_datapath]]
grid $data -column 1 -row 2 -columnspan 2 -sticky new
grid $data_lbl -column 1 -row 1 -columnspan 2 -sticky nsew
grid $isi -column 1 -row 2 -sticky nsw
grid $xt -column 1 -row 3 -sticky nsw
grid $ref -column 1 -row 4 -sticky nsw
grid $conf_button -column 2 -row 2 -rowspan 3 -sticky nsew
grid rowconfigure $frm 1 -weight 4 -uniform 1
grid rowconfigure $frm 2 -weight 1 -uniform 1
grid rowconfigure $frm_main 1 -weight 5 -uniform 1
$base
是使用创建的窗口的名称,toplevel
sparam_graph_widget
并且sparam_table_widget
是创建并放置在框架内的过程