halfcountplus has asked for the wisdom of the Perl Monks concerning the following question:
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"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk Text -font=>segfault
by thundergnat (Deacon) on Mar 28, 2008 at 01:37 UTC | |
|
Re: Tk Text -font=>segfault
by igelkott (Priest) on Mar 27, 2008 at 22:14 UTC | |
by halfcountplus (Hermit) on Mar 27, 2008 at 22:31 UTC | |
by BaldManTom (Friar) on Mar 27, 2008 at 23:04 UTC | |
|
Re: Tk Text -font=>segfault
by jdporter (Paladin) on Mar 28, 2008 at 01:30 UTC | |
|
Re: Tk Text -font=>segfault
by zentara (Cardinal) on Mar 28, 2008 at 15:05 UTC | |
|
Re: Tk Text -font=>segfault
by Anonymous Monk on Mar 28, 2008 at 09:07 UTC |