Hi All,
I am trying to re-write an older perl/Tk script that would download an image from a webcam and display it. I would like to use Gtk2 but there is very little example code and documentation available for it ( that I can find - any links would be appreciated ). This bit of code almost does what I need it to minus two things.
1. The image does not update.
2. The image does not scale when the window is resized.
One other thing, I would really like to avoid writing the data to a temp file if I can, I would rather download the image data and pipe it directly to Gtk2::Image.
Any help would be greatly appreciated !!
Thank You !
-T
#!/usr/bin/perl
$|=1;
use strict;
use Gtk2 '-init';
use MIME::Base64;
use LWP::Simple;
my $load_timeout = undef;
my $CAM_URL = "http://www.livecam.com.au/livecam1/livecam.jpeg?mu
+=";
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect(delete_event => \&delete_event);
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$window->set_border_width(10);
my $image = Gtk2::Image->new();
$window->add ($image);
$image->show;
$window->show;
$window->show_all;
do_load();
Gtk2->main;
sub do_load {
getstore($CAM_URL.time(),"/tmp/latest.jpg" );
$image->set_from_file("/tmp/latest.jpg");
$image->show;
$window->show;
unlink("/tmp/latest.jpg");
$load_timeout = Glib::Timeout->add (6500, \&do_load);
};
0;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.