srikrishnan has asked for the wisdom of the Perl Monks concerning the following question:
Dear All,
I am trying to write a perl script with perl Tk for GUI. The requirement is, if a user selects set of files, I want to display the files in the interface. In that they have to arrange them in the order they want, after they reorder I have to merge them.
But I dont know how to get the text of the selected check button for reordering the files.
my script is as follows:
use strict; use warnings; use Tk; use win32; use Win32::FileOp; use File::Find; my $filename; my $w; my $TagType; my $var; my $frame1; my $mw = new MainWindow; $mw -> setPalette('#EEEEEE'); $mw->resizable('no', 'no'); $mw -> title("get File List"); my $frame = $mw -> Frame -> pack (-side => 'top', -fill => 'both', -ex +pand => 1, -padx => '12', -pady => '12'); my $opt = $frame -> Optionmenu(-menu => $frame1, -command => sub {$Tag +Type = shift; if($TagType eq 1){&openFile}elsif($TagType eq 2){&openF +older}}, -variable => \$var,)->pack(-side => 'left', -anchor => 'nw') +; $frame1 = $frame -> Frame -> pack (-side => 'left'); $opt->addOptions(["select"=>0],["Add Files"=>1],["Add Folders"=>2]); my $frame3a = $mw -> Frame (-highlightthickness => '1', -highlightback +ground => 'black') -> pack (-side => 'top', -fill => 'both', -expand +=> 1, -padx => 12, -pady => '6'); $frame3a -> Label (-text => "Add Files, and then arrange them in the o +rder you want.", -font => 'Arial-Bold 11', -justify => 'left') -> pac +k (-anchor => 'w'); my $frame3 = $mw -> Frame -> pack (-side => 'top'); my $ins = $frame3 -> Scrolled("Text", -scrollbars => 'e', -width => '9 +0', -relief => 'flat', -highlightthickness => '1', -highlightbackgrou +nd => 'black') -> pack(-side => 'top', -padx => '12', -fill => 'both' +, -expand => 1); my $frame4 = $mw -> Frame (-highlightthickness => '1', -highlightbackg +round => 'black') -> pack (-side => 'top', -fill => 'both', -expand = +> 1, -padx => '12'); my $frame5 = $frame4 -> Frame -> pack (-side => 'left'); my $frame6 = $frame4 -> Frame -> pack (-side => 'left'); $frame6 -> Button (-text => 'Move Up', -command => \&moveUP, -backgrou +nd => '#E9F0F7', -activebackground => '#B8C4E5', -width => '11') -> p +ack (-side => 'top', -padx => '6', -pady => '10', -anchor => 'w'); my $frame7 = $frame4 -> Frame -> pack (-side => 'left'); $frame7 -> Button (-text => 'Move Down', -command => \&moveDown, -back +ground => '#E9F0F7', -activebackground => '#B8C4E5', -width => '11') +-> pack (-side => 'top', -padx => '0', -pady => '10', -anchor => 'w') +; my $frame8 = $frame4 -> Frame -> pack (-side => 'left'); $frame8 -> Button (-text => 'Remove', -command => \&removePages, -back +ground => '#E9F0F7', -activebackground => '#B8C4E5', -width => '11') +-> pack (-side => 'top', -padx => '6', -pady => '10', -anchor => 'w') +; my $frame10 = $mw -> Frame -> pack (-side => 'bottom', -fill => 'both' +, -expand => 1, -padx => '12'); my $frame11 = $frame10 -> Frame -> pack (-side => 'right'); $frame11 -> Button (-text => 'Cancel', -command => sub{$mw -> destroy; +}, -background => '#E9F0F7', -activebackground => '#B8C4E5', -width = +> '9') -> pack (-side => 'top', -pady => '10', -anchor => 'ne'); my $frame12 = $frame10 -> Frame -> pack (-side => 'right'); $frame12 -> Button (-text => 'Process', -command => \&process, -backgr +ound => '#E9F0F7', -activebackground => '#B8C4E5', -width => '9') -> +pack (-side => 'top', -padx => '0', -padx => '6', -pady => '10', -anc +hor => 'ne'); $mw->focusFollowsMouse; MainLoop; sub openFile { my $cb_value; my @types = (["3d Files",'.3d'], ["Excel Files",'.xls'], ["All fil +es", '*'] ); $filename = $mw->getOpenFile(-filetypes => \@types, -initialdir => $filename, -initialfile => $filename, -defaultextension => '.3d', -title=>'file to read'); + $mw->Unbusy; return 'Cancel' unless($filename); $mw -> update; $w = $ins -> Text (-height => '1', -font => 'Arial 10', -wrap => ' +word', -relief => "flat", -highlightbackground =>'white', -highlightt +hickness => '1', -highlightcolor => 'red'); $w -> insert('end', "$filename"); $ins->windowCreate('end', -window => $w); $w = $ins -> Checkbutton (-variable => \$cb_value, -command => sub + {print "$cb_value\n";}); $ins->windowCreate('end', -window => $w); } sub openFolder { } sub gotoSave { my $ExtractedStream = $w->get("1.0", "end"); print "$ExtractedStream"; # my ($first, $last) = $ins->get("1.0", "end"); # print "$first\n"; # print "$last\n"; } sub gotoClear { $ins -> delete ("1.0", "end"); } sub moveUP { } sub moveDown { } sub removePages { } sub process { }
Any help is greatly appreciated
Thanks in Advance
Srikrishnan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: TK Help
by thundergnat (Deacon) on Apr 30, 2010 at 14:28 UTC | |
by srikrishnan (Beadle) on May 04, 2010 at 03:41 UTC | |
by thundergnat (Deacon) on May 04, 2010 at 14:10 UTC | |
by srikrishnan (Beadle) on May 06, 2010 at 07:01 UTC | |
by afoken (Chancellor) on May 06, 2010 at 07:45 UTC | |
| |
by srikrishnan (Beadle) on May 08, 2010 at 04:24 UTC |