2012-08-01 2 views
0

위젯이있는 창이 있습니다. 수동으로 창 크기를 조정하면 높이가 줄어들 때 위젯의 크기가 조정되지만 너비가 변경되거나 높이가 초기 높이를 초과하여 확대되지 않을 때 위젯의 크기가 조정됩니다. 위젯을 창의 경계에 스택으로 만들려면 어떻게합니까?Tcl/Tk : 사용자가 창 크기를 변경할 때 위젯 크기를 조정하는 방법

윈도우의 생성을위한 코드 :

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 

$basetoplevel sparam_graph_widgetsparam_table_widget는 맞춤 위젯 그들에게 주어진 프레임 안에 생성 절차 및 장소 사용하여 만든 창 이름 그래프 및 테이블

답변

5

적어도 하나의 위젯이 공간을 소비하도록 확장하려면 최소한 하나의 열이 0이 아닌 가중치를 갖도록 설정해야합니다.

grid columnconfigure $containerWidget $someWidgetOrIndex -weight 1 

일단 그렇게하면 해당 열은 수평 방향의 모든 크기 변경을 우선적으로 처리합니다. 여러 개의 열을 0이 아닌 가중치로 설정하고 다른 열에 다른 가중치를 부여하여 조정할 수 있습니다 (-weight 2-weight 1의 두 배 큰 변경 사항을 받음).

사용 된 옵션을 외부 프레임 pack으로 조정해야 할 수도 있습니다. 서로 다른 프레임을 다른 색상으로 설정하여 디버그를하면 디버그가 진행됩니다.

관련 문제