The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

poe-yahoo-quotes.pl - TickerView and POE download and display of Yahoo stock quotes

SYNOPSIS

 ./poe-yahoo-quotes.pl symbol symbol ...

DESCRIPTION

This is some fun downloading share prices from Yahoo using POE for non-blocking HTTP in the GUI.

The default stock symbols are some miscellaneous shares and indexes, or a list of symbols can be given on the command line.

POE means the GUI continues to run and display while downloading. If you've got POE::Component::Client::DNS then the hostname lookup is asynchronous too. But get Client::DNS 1.04 or higher since previous versions only looked at the first name server in /etc/resolv.conf instead of going through all like the C library etc does. (Or if the first there is a local name server then make sure it forwards somewhere for hostnames it doesn't handle.)

The only tricky bit for POE and Gtk together is to note that some POE things can only be done from within a POE "current session". So the HTTP request in refresh_start() can't be initiated directly from the $refresh_button Gtk signal handler, instead that signal handler must POE::Kernel->post() a POE event which is queued and then from the main loop is dispatched to 'refresh_start' in $session. $session->postback creates an anonymous subr which does the post() -- it's a convenient way to create that glue when you don't need anything else in the Gtk handler.

POE HTTP is happy to send out multiple requests simultaneously and if you click the Refresh button a few times fast then that's what you get. In a real program you might want only one refresh in progress, or some limit on them. If you set $refresh_button to insensitive with $refresh_button->set_sensitive(0) then it stops the user clicking again, though as of Gtk 2.12 there's a long standing Gtk bug where if the mouse is in the button when you turn it back sensitive again then clicking does nothing until the user moves out and back in. (Botched maintenance of the "armed" ready-to-click.)

SEE ALSO

Gtk2::Ex::TickerView, POE, POE::Component::Client::HTTP, POE::Component::Client::DNS