I've hit a situation where using the "-font" option in defining a Tk Text widget leads to a Segmentation Fault. The version below works correctly unless you switch the comment-out from line 22 to line 20. Does anyone know why?
#!/usr/bin/perl -w use strict; use Tk; use Tk::NoteBook; my $MW = MainWindow->new(); my $note = $MW->Label(-font=>'courier-12',-text=> "F1-4 presents/withdraws the notebook windows.")->pack(); my (@VW, @NB, %pg, %txt); foreach (0..3) { my $title = eval("$_+1"); $VW[$_] = $MW->Toplevel(-title=>"$title"); $VW[$_]->state('wit +hdrawn'); $NB[$_] = $VW[$_]->NoteBook()->pack(); foreach my $L ("A","B","C","D") { my $name = "$L-$title"; $pg{$name} = $NB[$_]->add($name,-label=>'empty'); } } foreach (keys %pg) {$txt{$_} = $pg{$_}->Text()->pack()} # this version causes a seg fault: #foreach (keys %pg) {$txt{$_} = $pg{$_}->Text(-font=>"courier-12")->pa +ck()} $MW->bind('all',"<Key-F1>"=>sub{toggle(0)}); $MW->bind('all',"<Key-F2>"=>sub{toggle(1)}); $MW->bind('all',"<Key-F3>"=>sub{toggle(2)}); $MW->bind('all',"<Key-F4>"=>sub{toggle(3)}); MainLoop;################## sub toggle { my $n = "@_"; my $state = $VW[$n]->state(); my $newstate = ($state eq 'withdrawn') ? 'normal' : 'withdrawn +'; $VW[$n]->state("$newstate"); }
In reply to Tk Text -font=>segfault by halfcountplus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |