Reputation: 8941
I want to have a frame that fills the entire screen from left to right (because of the border relief) and the widgets inside it to stick to the left side. But when I put -sticky nswe
on the frame and -sticky nsw
on the widgets themselves, the frame takes the entire window, but the widgets are aligned to the left of the center of the frame and not to the left-most side of it:
and I want it to look like (created with paint):
And the code creating it is (for the upper frame, with the file extentions):
EDIT: added more of the code, and fixed the numbering issue of the columns and rows
proc eyes_view_create_file_extention_bar {frm_main listOfPossibleExtensions} {
#Files Extention Bar
set files_cb ::eyes_view_file_ext_arr_cb
grid [set file_frm [frame $frm_main.file_frm -relief groove -bd 2]] -row 0 -column 0 -columnspan 2 -sticky nswe
set file_lbl [label $file_frm.lbl -text "File Extenctions to Show:"]
set columns 0
foreach file_ext $listOfPossibleExtensions {
set cb [checkbutton $file_frm.[regsub -all {\.} $file_ext {}] -text $file_ext -variable ${files_cb}(${file_ext}) -command [list _eyes_view_update]]
set ${files_cb}(${file_ext}) 0
grid $cb -row 1 -column $columns -sticky wsn
incr columns
}
grid $file_lbl -row 0 -columnspan $columns -sticky wsn
}
proc eyes_view_main_widget {base listOfExternalVarsAndValues listOfPossibleExtensions} {
wm title $base "Eyes Viewer"
array set [set files_cb ::eyes_view_file_ext_arr_cb] {}
array set [set vars_cb ::eyes_view_vars_arr_cb] {}
set frm_main [frame $base.main_frm]
pack $frm_main -expand 1 -fill both
#graph
set g_frm [frame $frm_main.graph]
grid $g_frm -row 2 -column 1 -sticky nsew
set g [eyes_graph_widget $frm_main.graph graph]
#splits table
grid [set split_frm [frame $frm_main.tbl_split]] -row 2 -column 0 -sticky nswe
set apply_button [button $split_frm.apply -text "Apply" -command [list _eyes_view_update]]
set split_tbl_frm [frame $split_frm.tbl_frm]
set split_table [sparam_table_widget $split_tbl_frm split_table]
#file extensions frame, vars frame & legend
set file_frm [eyes_view_create_file_extention_bar $frm_main $listOfPossibleExtensions]
set var_frm [eyes_view_create_vars_values_bar $frm_main $listOfExternalVarsAndValues]
set legend_frm [eyes_view_create_legend_frame $frm_main]
grid $split_tbl_frm -row 0 -sticky nwse
grid $apply_button -row 1 -sticky nwse
grid columnconfigure $frm_main 0 -weight 0
grid columnconfigure $frm_main 1 -weight 1
grid rowconfigure $frm_main 0 -weight 0
grid rowconfigure $frm_main 1 -weight 0
grid rowconfigure $frm_main 2 -weight 1
grid rowconfigure $frm_main 3 -weight 0
grid rowconfigure $split_frm 0 -weight 1
grid rowconfigure $split_frm 1 -weight 0
...
return [list $g $split_table $legend_frm $frm_main]
}
Upvotes: 1
Views: 338
Reputation: 398
I could not reproduce your problem. After I fixed all the variables I got exactly the behavior you want. Maybe it's because this is not a complete script and there is something going on in what's left out. Anyway try the following:
Change
grid $file_frm -row 1 -column 1 -columnspan 2 -sticky nswe
to
grid $file_frm -row 1 -column 1 -columnspan 2 -sticky nswe
grid anchor $file_frm w
Upvotes: 1
Reputation: 33203
You need to tell the parent window ($frm_main) how you want it to propagate geometry changes to its children. In this case you probably want:
grid columnconfigure $frm_main 1 -weight 1
grid rowconfigure $frm_main 1 -weight 1
which says to give new space to row 1 column 1 when the parent size changes. It is worth reading the documentation on this quite carefully and using some simple frames with different colours (frame .f -background red and so on) to get a good idea of how grid works.
Your array handling is broken in the example too. The -variable option takes a variable name so you just want -variable files_cb($file_ext)
and you don't want to dereference when trying to set the array value either. Try set files_cb($file_ext) 0
instead.
Upvotes: 2