in reply to Re^6: Perl tk - open file and print content
in thread Perl tk - open file and print content
If you want to print multiple files, it might be best to push all file selections into an array, then send the whole
array to the printer, after selections are done. There are many ways to do it.
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
#!/usr/bin/perl use Tk; use strict; my $TOP = MainWindow->new; my $button = $TOP->Button(-text=> 'Print It' , -command => sub{ my $file_r = &fileDialog($TOP); print"\n selected this file $file_r\n"; # use whatever method you want to send # $file_r to the printer # like with Net::Cups print " printing now!\n"; # system( "lpr -lp0 -f $file_r"); #untested } )->pack(); MainLoop; sub fileDialog { my( $w ) = @_; my @types =( ["C files", [qw/.c++ .cpp .c/]], ["Log files", [qw/.log/]],, ["Text files", [qw/.txt/]], ["All files", '*'] ); my $file = $w->getOpenFile( -filetypes => \@types ); return($file); }
I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^8: Perl tk - open file and print content
by Giorgio C (Novice) on Jan 23, 2012 at 12:29 UTC | |
by Anonymous Monk on Jan 23, 2012 at 12:48 UTC | |
by Giorgio C (Novice) on Jan 23, 2012 at 14:44 UTC |
In Section
Seekers of Perl Wisdom