in reply to Perk TK : Child Window widgets

ComboBox has a default value and it look like when this
gets updated the object gets reset.
Look at lines 50 to 56 that I changed and it is working.

#!/usr/bin/perl use Tk; use Tk::JComboBox; my $screen_size = "1010x720+0+0"; my $tool_name='Testing Interface'; &Screen(); MainLoop; #-------Drawing User interface screeen---------------------- sub Screen { $main_screen_object = MainWindow->new(-bg => 'white'); $main_screen_object->geometry($screen_size); $main_screen_object->title($tool_name); createButton('CREATE NEW WINDOW',15,490,150,$main_screen_object); } #-------Callback function 'CREATE NEW WINDOW' button------------------ +------ sub onCREATENEWWINDOWButtonClick { $main_screen_object->update(); $CopyWindow=$main_screen_object->Toplevel(-height => 240, -width = +> 270, -background => 'white', -title => 'Copy Mapping') or die "coul +d not instant\n"; createLabel('COUNTRY',30,25,undef,undef,undef,$CopyWindow); our @CountryCodesList=qw /HD NK ID LK/; createComboBox('CountryCodes',10,140,25,$CopyWindow); } sub onCountryCodeComboBoxSelect { } #-------createLabel() - Used to create the label widget for given conf +iguration--------------- sub createLabel { my($LabelName,$x,$y,$background,$Font,$Foreground,$Object) = @_; $Font = 'verdana 10 bold' unless defined $Font; $background = 'white' unless defined $background; $Foreground = '#015F96' unless defined $Foreground; my($LabelNameObject); if ( defined($Object) ) { $LabelNameObject = $Object->Label(-background =>$background,-t +ext =>$LabelName,-font =>$Font,-foreground =>$Foreground)->place(-x=> +$x,-y=>$y); } else { $LabelNameObject = $main_screen_object->Label(-background =>$b +ackground,-text =>$LabelName,-font =>$Font,-foreground =>$Foreground) +->place(-x=>$x,-y=>$y); } return($LabelNameObject); } #-------createComboBox() - Used to create the combobox widget for give +n configuration--------------- sub createComboBox { my($ComboBoxName,$Width,$x,$y,$Object) = @_; $ComboBoxName =~ s/\s+//g; #--------------------------------------------------------- #--------------------------------------------------------- # the combobos list get update with the last select value # that is way I plased this line here and it is working my @combolist = @{$ComboBoxName."List"}; #--------------------------------------------------------- #--------------------------------------------------------- my $ComboBoxObject = $Object->JComboBox(-background =>'white', -textvariable => \${$ComboBoxName}, -choices => \@combolist, -browsecmd =>\&{"on".$ComboBoxName."ComboBoxSelect"} +, -font =>'verdana 10', -relief => 'solid', -borderwidth => 1, -entrywidth => $Width ) ->place(-x=>$x,-y=>$y) or die "Error $! \n\n"; return($ComboBoxObject); } #-------createButton() - Used to create the button widget for given co +nfiguration--------------- sub createButton { my($ButtonLabel,$Width,$x,$y,$Object) = @_; my($ButtonObject); my $ButtonName = $ButtonLabel; $ButtonName =~ s/\s+//g; $ButtonObject = $Object->Button(-background =>'grey', -text =>"$ButtonLabel", -font =>'verdana 10 bold', -foreground =>'black', -disabledforeground => '#90938D', -activebackground=>'#4A71AD', -activeforeground => 'white', -relief => 'solid', -borderwidth => 1, -width =>$Width, -command =>\&{"on".$ButtonName."Button +Click"})->place(-x=>$x,-y=>$y); return($ButtonObject); }

Replies are listed 'Best First'.
Re^2: Perk TK : Child Window widgets
by selva (Scribe) on Jul 31, 2010 at 11:31 UTC

    Hi Generoso

    It is working fine. Thank you very much for your quick answer