I will try to be brief with a problem that I have, even though I am not good in being brief. Thanks to all of you who bothered reading it.
I am using perl 5.8 and Tk on a Powerbook, for the past 2 weeks. My experience is minimal but I am tryingl. So while experiencing with Perl and TK I found a module called Tk:Columns so I build a notebook with 3 tabs, and in the 3rd tab, I have a browse button, which selects though a widget only perl files. Once a perl file is selected the insert button put it in the 1st row
1) I have done something wrong, and when I select the next perl file to be inserted it doesn't. Somehow my lame programming points at the previous entry.
2) Each column is responsible to do one thing. I need to implement the following but currently I can not.
1st column should have a number as a reference and increase each time a new line is inserted. So something like $myref = $Row++; which i can't get it to work.How can I refer to the current row ?
2nd column should show the file. I figured out how to trim the long path and return only the filename, but I have the problem with the pointer mentioned above.
4th Column should have 3 possible dynamic entries, Running, Finished, Failed. How can I check, if a perl program is still running, if there is an error or if it is done. I know how I can execute a perl script and grab its outpt on a text widget.
5th Column should have a button. Start to start executing the script and stop to stop it. I can do a start button not in the Column widget but how do I assosicate the file name in the 2 column so it can be executed. how can I stop it as well ?
6th Column , I Think this is the most tricky part. Once the perl scripts, which are not mine are done they generate the output which is vital to me. so filename1.pl should generate in the same folder filename1.log The log is not generated in once, the perl files open and close this filename.log continuously until they finish. How can I understand they have finished and make a button that can open the generated log file in another text widget.
Perhaps my implemention is wrong, so if u suggest alternatives I am glad to follow, in addiion i have read all the newsgroup but apparently there is no way to configure notebook tabs on the right or vertical ?
use Tk;
use English;
use File::Basename;
use Cwd;
require Tk::FileSelect;
require Tk::Dialog;
require Tk::HList;
use diagnostics -verbose;
use Tk::Columns;
use Tk::DialogBox;
use Tk::NoteBook;
use Tk::ROText; # and Read-only text box for output panes
#########################################################
## MAIN WINDOW
+ #
#########################################################
my $main = MainWindow->new();
$main->title('My TK_app ');
$main->geometry('800x600');
### A notebook consisted of 3 pages ########
my $notebook = $main->NoteBook(
-dynamicgeometry => 'true',
-ipadx => 20,
-ipady => 6
);
$notebook->pack(
-expand => "yes",
-fill => "both",
-padx => 3,
-pady => 3,
-side => "top"
);
# Divide the working area into
my $Config_p = $notebook->add( "config", -label => "Config", -underlin
+e => 0 );
my $Tc_p = $notebook->add( "Tc", -label => "Test cases", -underline =>
+ 0 );
my $Viewlog_p = $notebook->add( "Viewlog", -label => "Logs", -underlin
+e => 0 );
## 1ST TAB ##################
$input_text_area = $Config_p->Scrolled(
'Text',
-wrap => "none",
-scrollbars => "se",
-width => 40,
-height => 25,
-background => 'WhiteSmoke'
);
$input_text_area->pack( -side => "top", -expand => 1, -fill => 'both'
+);
$input_text_area->focus(); # gets focus on startup
## 2ST TAB ##################
my $l_Window = $Tc_p->TableEdit( '-file' => 'test.dat', );
$l_Window->Item(
'Entry',
'-name' => 'Date',
'-default' => sub { localtime(); },
);
$l_Window->Item(
'Entry',
'-bg' => 'white',
'-relief' => 'sunken',
'-name' => 'Internet Address',
'-expression' => [
'^[0-9]{1,3}?$',
'^[0-9]{1,3}?\.$',
'^[0-9]{1,3}?\.[0-9]{1,3}?$',
'^[0-9]{1,3}?\.[0-9]{1,3}?\.$',
'^[0-9]{1,3}?\.[0-9]{1,3}?\.[0-9]{1,3}?$',
'^[0-9]{1,3}?\.[0-9]{1,3}?\.[0-9]{1,3}?\.$',
'^[0-9]{1,3}?\.[0-9]{1,3}?\.[0-9]{1,3}?\.[0-9]{1,3}?$',
],
);
$l_Window->pack( '-expand' => 'true', '-fill' => 'both' );
$l_Window->GeometryRequest( 400, 200 );
################## 3RD TAB ##################
$inputfr = $Viewlog_p->Frame(
-relief => 'groove',
-label => 'Test cases panel',
-borderwidth => 3,
)->pack(
-side => 'top',
-anchor => 'nw',
-fill => 'both',
);
$incol1fr = $inputfr->Frame(
-borderwidth => 2,
)->pack(
-side => 'left',
-anchor => 'nw',
-fill => 'both',
);
$incol2fr = $inputfr->Frame(
-borderwidth => 2,
)->pack(
-side => 'left',
-anchor => 'nw',
-fill => 'both',
);
$incol3fr = $inputfr->Frame(
-borderwidth => 2,
)->pack(
-side => 'left',
-anchor => 'nw',
-fill => 'both',
);
# Annotation File #
$incol1fr->Label( -text => 'Please select your testcase file (*.pl)',
+)->pack(
-side => 'top',
-anchor => 'ne',
-pady => 3,
);
$testfile_e = $incol2fr->Entry(
-text =>'No file selected',
-state => 'normal',
-textvariable => \$testfile_e,
-width => 60,
)->pack(
-side => 'top',
-anchor => 'nw',
-pady => 3,
);
$incol3fr->Button(
-text => 'Browse',
-command => [ \&selectsinglefile, \$testfile_e, \$main ],
-borderwidth => 1,
-padx => 0,
-pady => 0,
)->pack(
-side => 'top',
-anchor => 'nw',
);
######## Insert Delete buttons ##############
my $but_frame = $Viewlog_p->Frame();
$but_frame->pack(
-side => 'bottom',
-anchor => "sw",
-expand => 0,
-fill => 'x',
-padx => 0
);
$but_frame->Button(
-text => 'Insert',
-command => [ \&add_lines ],
-borderwidth => 1,
-padx => 0,
-pady => 0,
)->pack(
-side => 'left',
-anchor => 'nw',
);
$but_frame->Button(
-text => 'Delete all',
-command => [ \&del_lines ],
-borderwidth => 2,
-padx => 0,
-pady => 0,
)->pack(
-side => 'left',
-anchor => 'nw',
);
###################### Columns *****************#################
+##
my $Columns = $Viewlog_p->Columns
(
'-columnlabels' => [qw (No File Date Status Action log )],
'-width' => '20',
'-height' => '60',
'-sortcommand' => '$a cmp $b',
'-listforeground' => 'blue4',
'-listbackground' => 'beige',
'-buttonbackground' => 'gray',
'-buttonforeground' => 'black',
'-selectmode' => 'extended',
'-trimcount' => '2',
'-sort' => 'true',
);
$Columns->pack(
'-anchor' => 'sw',
'-expand' => 'false',
'-side' => 'top',
'-fill' => 'both',
);
MainLoop;
sub selectsinglefile {
my $entryblankref = shift;
my $entryblank = $$entryblankref;
my $mwref = shift;
my $mw = $$mwref;
my $filetypes = [ [ 'Perl test cases ', ['.pl'] ], [ 'All files',
+['*'] ] ];
my $file = $mw->getOpenFile(
-title => "Please choose a configuration file",
-filetypes => $filetypes,
-defaultextension => ".pl"
);
if ( defined $file and $file ne '' ) {
$entryblank->delete( 0, 'end' );
$entryblank->insert( 0, $file );
$entryblank->xview('end');
}
}
sub add_lines {
$time=localtime();
($base,$path,$type) = fileparse($testfile_e);
$Columns->insert( '0', 1, $base, $time, 'Running', 'Start', 'Not
+ready' );
}
sub del_lines {
$Columns->delete( 0, 'end' );
}