2017-02-14 4 views
0

私は、下の画像に示すように、「キー」列、「値」列、および「新しい値」列を含む表を作成しました。 「キー」と「値」の列はラベルとして実装されています。「値」列は表示されているとおりにラップされています。 「新しい値」列は編集可能であるため、入力ウィジェットとして実装されています。値を[新しい値]入力フィールドにコピーするコピー& [貼り付け]ボタンがあります。 Entryウィジェットでテキストを折り返したいので、ボタンを押すと "Value"フィールドのテキストのように見えます。ここPerl TK - エントリーウィジェットのテキストを囲む

Image that shows the table I built and the difference between the wrapped Label to the text in the Entry field

示す列を定義するコードの一部である:

 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 => [\&copy_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); 

答えて

0

Tkの::テキストウィジェットは、通常、Tkを組み合わせる複数行のテキストエントリのためのものです: :スクロール、次のようなもの:

my $new_val_entry = $table->Scrolled(
    'Text', 
    -width  => 40, 
    -height  => 3, 
    -wrap  => 'word', 
    -scrollbars => 'e', 
    -font  => $my_font, 
)->pack(
    -expand => 1, 
    -fill => 'both', 
    -padx => 5, 
    -pady => 5, 
); 
+0

ありがとうStefan! Tk :: Textを使って問題を解決しました。 – Eliad1983

関連する問題