cniggeler has asked for the wisdom of the Perl Monks concerning the following question:
but I get this error message:my $newfont = ''; # maybe font value read from user, results in # $newfont = "{liberation sans} 8 normal"; my $opt = "-fg => $fg, -bg => $bg"; $opt .= ", -font => $newfont" if length($newfont); $rw->Label(-text => "Col. 1", $opt, -padx => 10)->grid( $rw->Label(-text => "Col. 2", $opt, -padx => 11), $rw->Label(-text => "Col. 3", $opt, -padx => 11))
Nothing I could think of, including escaped quotes or eval(), has gotten around it, so for now I use an if-else that checks length($newfont) and repeats the Label widget creation, once with and once without -font. Is this possible? I lack detailed perl knowledge, so probably something like \$${opt} would do the trick :-) Thanks!Tk::Error: Odd number of args to Tk::Label->new(...)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: tk option+value in variable?
by choroba (Cardinal) on Jan 25, 2019 at 20:51 UTC | |
by cniggeler (Sexton) on Jan 25, 2019 at 21:04 UTC | |
by cniggeler (Sexton) on Jan 25, 2019 at 22:01 UTC | |
by choroba (Cardinal) on Jan 25, 2019 at 22:15 UTC | |
by AnomalousMonk (Archbishop) on Jan 26, 2019 at 01:28 UTC | |
by cniggeler (Sexton) on Jan 26, 2019 at 16:04 UTC | |
|