User Control Panel
Advertisements

HELP US, HELP YOU!

Tk not printing

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Review
View unanswered posts
Author Message
Addict
Not Yet a God
Not Yet a God


Joined: 21 Jan 2004
Posts: 473

Reputation: 34.4Reputation: 34.4Reputation: 34.4

PostPosted: Mon Mar 28, 2005 9:15 am    Post subject: Reply with quote

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! Smile
Back to top
..::BIGmouth( )::..
God Like
God Like


Joined: 05 Feb 2004
Posts: 801

Reputation: 44.1Reputation: 44.1Reputation: 44.1Reputation: 44.1

PostPosted: Mon Mar 28, 2005 2:03 pm    Post subject: Reply with quote

$mw->Label(-text => &getforcast($zip))->pack();
print is only for the perl dos.
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Mon Mar 28, 2005 4:17 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Code Review All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group