User Control Panel
|
|
|
 |
Advertisements
|
 |
|
|
|
HELP US, HELP YOU!
|
| Author |
Message |
Addict Not Yet a God

Joined: 21 Jan 2004 Posts: 473
   
|
Posted: Mon Mar 28, 2005 9:15 am Post subject: |
|
|
I'm trying to get this code:
| Code: | | #!/usr/bin/perl<br /><br />use Tk;<br />use Tk::ROText;<br />use LWP::Simple;<br /><br />my $mw = new MainWindow(-title => "Weather Matrix");<br /> $mw->geometry('400x450');<br /><br /> $mw->Label(-text => "City:")->pack();<br /> $mw->Entry(-background => "white",-width => 20,-textvariable => \$zip)->pack();<br /> $mw->Button(-text => 'Weatherize', -command => \&weather)->pack();<br /><br />my $text = $mw->Scrolled ('ROText',<br />-wrap => 'word',<br />-scrollbars => 'oe',<br />)->pack (-expand => 1);<br />my $realtext = $text->Subwidget('rotext');<br />tie *STDOUT, ref $realtext, $realtext;<br /><br />MainLoop;<br /><br /># getforcast sub coded by Matt Austin.<br />sub getforcast{<br /> my $zip = shift;<br /> my ($forcast);<br /> my $data = get("http://www.weather.com/weather/mpdwcr/narrative?locid=$zip");<br /> while($data =~ m/day.*?\),'\d','(.*?)','(\w+)'\)/g){<br /> my ($day, $text) = ($2, $1);<br /> $forcast .= "$day: $text\n";<br /> return $forcast;<br /> }<br />}<br /><br />sub weather {<br />my $zip = shift;<br />print getforcast($zip);<br />} |
To print the weather information of the zip code I enter into the text box. It doesn't print it into the output area like it's supost to. :unsure:
Thanks for reading!  |
|
| Back to top |
|
 |
..::BIGmouth( )::.. God Like

Joined: 05 Feb 2004 Posts: 801
    
|
Posted: Mon Mar 28, 2005 2:03 pm Post subject: |
|
|
$mw->Label(-text => &getforcast($zip))->pack(); print is only for the perl dos. |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Mon Mar 28, 2005 4:17 pm Post subject: |
|
|
In Tk, you can tie STDOUT to a text box.
| Code: | | $text = $GUI->Scrolled ('ROText',<br /> -foreground => $top,<br /> -background => $bottom,<br /> -wrap => 'word',<br /> -scrollbars => 'oe',<br /> -font => [<br /> -family => 'Courier New',<br /> -size => 10,<br /> ],<br />)->pack (-fill => 'both', -expand => 1);<br />my $realtext = $text->Subwidget ('rotext');<br /><br /># Tie STDOUT to this.<br />tie *STDOUT, ref $realtext, $realtext; |
_________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
|
|