我创建了一个包含“键”列、“值”列和“新值”列的表,如下图所示。“Key”和“Value”列被实现为标签,“Value”列被包装,如您所见。“新值”列被实现为条目小部件,因为它应该是可编辑的。有一个复制和粘贴按钮,可将值复制到“新值”输入字段。我想将文本包装在 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);