Example : dlg_selectFromList.pl

#!perl.exe
## ctk: description Select items from list
## ctk: title Select from List
## ctk: application '' ''
## ctk: strict
1
## ctk: code 0
## ctk: subroutineName selectFromList
## ctk: autoExtractVariables 1
## ctk: autoExtract2Local 1
## ctk: modalDialogClassName DialogBox
## ctk: modal 1
## ctk: isolGeom 0
## ctk: version 3.099
## ctk: onDeleteWindow sub{1}
## ctk: Toplevel
1
## ctk: argList -data, \@testItems, -title , 'Select
from list'
## ctk: 2007 11 13 - 11:58:32
## ctk: uselib start
## ctk: uselib end
use strict;
use Tk;
use Tk::Label;
use Tk::Listbox;
my
$mw=MainWindow->new(-title=>'Select from List');
## ctk: Globalvars
use vars qw/@testItems/;
## ctk: Globalvars end
&main::init();
my $answer = &main::selectFromList($mw,-data,
\@testItems, -title , 'Select from list'
);
print "\nanswer = '$answer'";
MainLoop;
sub selectFromList {
my $hwnd = shift;
my (%args) = @_;
my $rv;
##
## ctk: Localvars
## ctk: Localvars end
##
my $mw = $hwnd->DialogBox(
-title=>
(exists $args{-title})? $args{-title}:'Select from List',
-buttons=> (exists $args{-buttons}) ?
$args{-buttons} : ['OK','Cancel']);
$mw->protocol('WM_DELETE_WINDOW',sub{1});
## ctk: code generated by ctk_w version '3.099'
## ctk: lexically scoped variables for widgets
my ($wr_002,$wr_003 );
## ctk: instantiate and display widgets
$wr_002 = $mw -> Listbox ( -background , '#ffffff'
, -selectmode , 'extended' , -relief , 'sunken' ) -> pack(-side=>'top', -anchor=>'nw', -pady=>2,
-fill=>'both', -expand=>1, -padx=>2);
$wr_002->insert('end',@{$args{-data}});
$wr_002->selectionClear(0,'end');
$wr_002->update();
$wr_003 = $mw -> Label ( -justify , 'left' , -text
, 'Select one of the items listed
above.' , -relief , 'flat' ) ->
pack(-side=>'top', -anchor=>'nw', -pady=>2, -fill=>'both',
-expand=>1, -padx=>2);
## ctk: end of gened Tk-code
$rv =
$mw->Show();
return $rv;
} ## end of selectFromList
## ctk: end of dialog code
## ctk: callbacks
sub init {
@testItems =
(qw/item_first item_next_1 item_next_2 item_last/);
}
sub update {
$mw->update();
}
## ctk: other code
## ctk: eof 2007 11 13 - 11:58:32
1; ## make perl
compiler happy...
## ctk: description Select items from list
## ctk: title Select from List
## ctk: application '' ''
## ctk: strict
1
## ctk: code 0
## ctk: subroutineName selectFromList
## ctk: autoExtractVariables 1
## ctk: autoExtract2Local 1
## ctk: modalDialogClassName DialogBox
## ctk: modal 1
## ctk: isolGeom 0
## ctk: version 3.099
## ctk: onDeleteWindow sub{1}
## ctk: Toplevel
1
## ctk: argList -data, \@testItems, -title , 'Select
from list'
## ctk: 2007 11 13 - 12:06:20
use strict;
use Tk;
use Tk::Label;
use Tk::Listbox;
sub selectFromList {
my $hwnd = shift;
my (%args) = @_;
my $rv;
##
## ctk: Localvars
## ctk: Localvars end
##
my $mw = $hwnd->DialogBox(
-title=>
(exists $args{-title})? $args{-title}:'Select from List',
-buttons=> (exists $args{-buttons}) ?
$args{-buttons} : ['OK','Cancel']);
$mw->protocol('WM_DELETE_WINDOW',sub{1});
## ctk: code generated by ctk_w version '3.099'
## ctk: lexically scoped variables for widgets
my ($wr_002,$wr_003 );
## ctk: instantiate and display widgets
$wr_002 = $mw -> Listbox ( -background , '#ffffff'
, -selectmode , 'extended' , -relief , 'sunken' ) -> pack(-anchor=>'nw', -side=>'top', -pady=>2,
-fill=>'both', -expand=>1, -padx=>2);
$wr_002->insert('end',@{$args{-data}});
$wr_002->selectionClear(0,'end');
$wr_002->update();
$wr_003 = $mw -> Label ( -justify , 'left' , -text
, 'Select one of the items listed above.'
, -relief , 'flat' ) ->
pack(-anchor=>'nw', -side=>'top', -pady=>2, -fill=>'both',
-expand=>1, -padx=>2);
## ctk: end of gened Tk-code
$rv =
$mw->Show();
return $rv;
} ## end of selectFromList
## ctk: end of dialog code
## ctk: callbacks
sub update {
$mw->update();
}
## ctk: other code
## ctk: eof 2007 11 13 - 12:06:20
1; ## make perl
compiler happy...
2007 11 13 - 12:05:05 . , perl.exe
2007 11 13 - 12:05:05 ctk_w.exe starting under
'MSWin32'
2007 11 13 - 12:05:05 Session 'Tkadmin' successfully
restored.
2007 11 13 - 12:05:05 Version '3.099'
2007 11 13 - 12:05:05 Widget class Tk::Pane does not
exist yet, discarded
2007 11 13 - 12:05:05 Widget class Tk::TextList does
not exist yet, discarded
2007 11 13 - 12:06:02 Exporting project
'dlg_selectFromList.pl'
2007 11 13 - 12:06:21 Project
'dlg_selectFromList.pl' successfully
exported to 'C:/Dokumente und
Einstellungen/marco/Utilities/ClickTk/test/dlg_selectFromList.pl'.
2007 11 13 - 12:06:24 Session 'Tkadmin' successfully
saved.
ctk_w.exe ended