in reply to Tk::Optionbox default [Solved]

Hi jinnicky,

Another alternative which seems to work is to change -variable to -textvar:

#!/usr/bin/perl -w use strict; use warnings; use feature qw{ say }; use Tk; use Tk::Optionbox; my $default_vsel = "Amazon"; my @options = ( 'option1', 'option2', $default_vsel, 'option4', ); my $mw = Tk::MainWindow->new(-title => 'Tk::Optionbox exampl +e'); my $vsel = $default_vsel; my $variableFont = 'Arial'; my $newTop = $mw->Frame->pack(-expand => 1, -fill => 'x'); my $selectVendor = $newTop->Optionbox( -command => \&select_vendor, -textvar => \$vsel, -font => $variableFont, -options => [@options], -rows => 15, )->pack(-side=>'left'); Tk->MainLoop; sub select_vendor { my $vendor = shift; say "Vendor is '$vendor'"; }
say  substr+lc crypt(qw $i3 SI$),4,5

Replies are listed 'Best First'.
Re^2: Tk::Optionbox default
by jinnicky (Sexton) on Apr 11, 2015 at 17:43 UTC
    Thanks thundergnat and golux Both solutions work.