下の画像に示すように、「キー」列、「値」列、および「新しい値」列を含むテーブルを作成しました。「キー」列と「値」列はラベルとして実装され、「値」列はご覧のとおりラップされています。「新しい値」列は、編集可能にする必要があるため、エントリ ウィジェットとして実装されます。値を [新しい値] エントリ フィールドにコピーする [コピー & ペースト] ボタンがあります。Entry ウィジェットでテキストをラップしたいので、ボタンを押すと、「値」フィールドのテキストのようになります。
作成したテーブルと、ラップされたラベルと入力フィールドのテキストの違いを示す画像
表示される列を定義するコードは次のとおりです。
my $key_label = $table->Label(-text => $key , -width => 50, -bg => $background_color, -anchor => 'w', -relief => $relief_style, -wraplength => 300)->pack(-side => 'left');
$table->put($curr_row,1,$key_label);
my $orig_val_label = $table->Label(-text => $full_cfg_hash{$key}{'old_value'}, -width => 50, -bg => $background_color, -anchor => 'w', -relief => $relief_style, -wraplength => 300)->pack(-side => 'left');
$table->put($curr_row,2,$orig_val_label);
my $new_val_entry = $table->Entry(-text => $full_cfg_hash{$key}{'new_value'}, -width => $entry_size, -bg => $background_color)->pack( -side => 'left', -fill => 'both', -expand => 'yes');
$table->put($curr_row,3,$new_val_entry);
my $copy_paste_btn = $table->Button(-text => "Copy & Edit\nOld Value", -command => [\©_n_edit_old_value,$full_cfg_hash{$key}{'old_value'},$new_val_entry], -bg => $buttons_background, -foreground => $buttons_text_color)->pack(-side => 'left', -padx => 5);
$table->put($curr_row,4,$copy_paste_btn);