You are not logged in.
Pages: 1
Hi,
I recently made a script to help my church's not-so-computer-adept webmaster.
I then decided to "gui-fy" it with perl tk, which looks lik this: http://www.pastie.org/520394. (EDIT: link was not working)
#!/usr/bin/perl -w
use Tk;
use strict;
my $mw = MainWindow -> new;
$mw -> geometry( "200x250" );
$mw -> title( "Button Test" );
$mw -> Label( -text => "Date: ") -> pack();
my $date_entry = $mw -> Entry() ->pack();
$mw -> Label( -text => "Sermon Name: ") -> pack();
my $sermon_entry = $mw -> Entry() ->pack();
$mw -> Label( -text => "Pastor: ") -> pack();
my $pastor_entry = $mw -> Entry() ->pack();
$mw -> Label( -text => "mp3 File (with .mp3 attached ): ") -> pack();
my $mp3_entry = $mw -> Entry() ->pack();
my $button1 = $mw->Button(-text => "Ok", -command => \&button1_sub)->pack();
sub button1_sub
{
my $date = $date_entry->get();
my $sermon = $sermon_entry->get();
my $pastor = $pastor_entry->get();
my $mp3 = $mp3_entry->get();
my $yesno_button = $mw -> messageBox( -message => "Date: $date\nSermon Name: $sermon\nPastor: $pastor\nmp3: $mp3\nIs this correct?", -type => "yesno" );
if ( $yesno_button eq "Yes" )
{
open TABLE, "table.html" or die "Could not opn file: $!\n";
my @table = <TABLE>;
my @first = @table[0..6];
my @second = @table[7..$#table];
my @newhtml = (
"<TR>",
"<TD vAlign=top width=\"10%\"><p class=sermondate>$date</p></td>",
"<TD vAlign=top width=\"60%\"><p class=sermonseason>$sermon</p></td>",
"<TD vAlign=top width=\"20%\"><p class=sermonspeaker>$pastor</p></td>",
"<TD vAlign=top width=\"10%\"><p class=sermonlink><A href=\"$mp3\">Listen</a></p></td>"
);
#puts the arrays back together
push ( @first, @newhtml );
my @new = ( @first, @second );
open OUTPUT, ">table.html" or die "Couldn't write to file: $!\n";
close OUTPUT or die "Error closing file: $!\n";
}
}
MainLoop;
It opens fine:
http://lh5.ggpht.com/_G5Oc_XJPXIE/Sj-28 … shot_1.jpg
Your can enter text fine:
http://lh4.ggpht.com/_G5Oc_XJPXIE/Sj-28 … shot_2.jpg
It even reconizes the text fine:
http://lh6.ggpht.com/_G5Oc_XJPXIE/Sj-28 … enshot.jpg
but then it wipes "table.html" ( http://www.pastie.org/520389 )
Any ideas on this?
All help is greatly appreciated
-jhl
Last edited by luskjh (2009-06-22 17:08:12)
Calm down, it is only ones and zeroes.
-flyingfsck ( on /. )
Offline
open OUTPUT, ">table.html" or die "Couldn't write to file: $!\n"; close OUTPUT or die "Error closing file: $!\n";
but then it wipes "table.html" ( http://www.pastie.org/520389 )
You're not writing the table to the file.
Add this between the two lines above:
print OUTPUT join("\n", @new);
If that doesn't work I'll take another look at it. I only skimmed your code because you use different conventions than I do so I may have missed something.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Oh, Thanks *slaps forehad* I took that out when I copy/pasted the code, for some reason thinking it had to do with th command line version .
Anyway, thanks again
-jhl
Calm down, it is only ones and zeroes.
-flyingfsck ( on /. )
Offline
Forehead-slapping moments are an integral part of programming.
If the code works the way that you want it to now, then please edit the original post and add "[SOLVED]" to the beginning of the subject line.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Pages: 1