テキストウィジェットの行番号を印刷するには、次のコードを使用します。
my $c = 0;
my $r = 0;
$txt = $mw->Text(
-background => 'white',
-width => 400,
-height => 300,
-selectbackground => 'skyblue',
-insertwidth => 5,
-borderwidth => 3,
-highlightcolor => 'blue', # after visit
-highlightbackground => 'red', # default before visit
-xscrollcommand => sub { print "CHAT NO :", $c++; },
# Determines the callback used when the Text widget is scrolled horizontally.
-yscrollcommand => sub { print "LINR NO:", $r++; },
# Determines the callback used when the Text widget is scrolled vertically.
-padx => 5,
-pady => 5,
)->pack();
上記のコードは行番号と文字番号を正常に印刷していますが、スクロールウィジェットで使用すると、出力は印刷されません。次のコードの問題は何ですか?どうすればこれを解決できますか?
$txt = $mw->Scrolled('Text',
-scrollbars => 'se',
-background =>'white',
-width => 400,
-height => 300,
-insertwidth => 5,
-borderwidth =>3,
-highlightcolor => 'blue', # after visit
-highlightbackground => 'red' , # default before visit
-padx => 5,
-pady => 5,
# Determines the callback used when the Text widget is scrolled horizontally.
-xscrollcommand => sub { print"CHAT NO :",$c++; },
# Determines the callback used when the Text widget is scrolled vertically.
-yscrollcommand => sub { print"LINR NO :",$r++; },
)->pack();