Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: TK Help

by srikrishnan (Beadle)
on May 08, 2010 at 04:24 UTC ( [id://838997]=note: print w/replies, xml ) Need Help??


in reply to Re^3: TK Help
in thread TK Help

Hi thundergnat

Again I thanks you for your sample. From the sample you have given, i got a idea of using "Listbox" option for my requirement. Also I have tried that with success

Below I have pasted my final completed code, may be it would be useful for somebody

use strict; use warnings; use Tk; use Tk::ROText; use win32; use Win32::FileOp; use File::Find; use Tk::LabFrame; use Tk::LabEntry; my @filename; my $w; my $TagType; my $var; my $fileList; 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 $frame1 = $frame -> Frame -> pack (-side => 'left'); $frame1 -> Button (-text => 'Add Files...', -command => \&openFile, -b +ackground => '#E9F0F7', -activebackground => '#B8C4E5') -> pack (-sid +e => 'top', -padx => '0', -pady => '10', -anchor => 'e'); my $frame3a = $mw -> Frame () -> pack (-side => 'top', -fill => 'both' +, -expand => 1, -padx => 12, -pady => '6'); my $frame3 = $frame3a -> LabFrame (-label => "Add Files, and then arra +nge them in the order you want.", -font => 'Arial-Bold 11', -labelsid +e => "acrosstop") -> pack (-anchor => 'w'); my $ins = $frame3 -> Scrolled("Listbox", -scrollbars => 'e', -width => + '90', -background => 'white') -> pack(-side => 'top', -pady => '12', + -padx => '12', -fill => 'both', -expand => 1); my $frame4 = $frame3 -> Frame () -> pack (-side => 'top', -fill => 'bo +th', -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'); MainLoop; sub openFile { my @types = ( [ "3d Files", '.3d' ], [ "All files", '*' ] ); @filename = $mw->getOpenFile( -filetypes => \@types, -defaultextension => '.3d', -title => 'file to read', -multiple => 1, ); $mw->Unbusy; return 'Cancel' unless (@filename); foreach my $single(@filename) { $ins->insert( 'end', "$single" ); } } sub gotoSave { my $ExtractedStream = $w->get("1.0", "end"); print "$ExtractedStream"; } sub gotoClear { $ins -> delete ("1.0", "end"); } sub moveUP { my @fileList = $ins->curselection(); my $selIndex = $fileList[0]; $selIndex = $selIndex-1; $fileList = $ins->get(@fileList); $ins->delete(@fileList); $ins -> insert($selIndex, $fileList); $ins->selectionSet($selIndex); } sub moveDown { my @fileList = $ins->curselection(); my $selIndex = $fileList[0]; $selIndex = $selIndex+1; $fileList = $ins->get(@fileList); $ins->delete(@fileList); $ins -> insert($selIndex, $fileList); $ins->selectionSet($selIndex); } sub removePages { my @fileList = $ins->curselection(); $ins->delete(@fileList); } sub process { my @colList = $ins -> get(0, 'end'); my $count = 1; foreach my $single(@colList) { print "$count\. $single\n"; $count++; } }

I have learned the following new things from your code

1. gif as a data within perl script

2. -multiple file selection option in "getOpenFile"

3. DragDrop and DropSite modules

4. Different way of coding with Tk

Once again thanks for teaching me all these things from a discussion

Thanks

Srikrishnan R.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://838997]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 21:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found