1: #!/usr/bin/perl -w
2: # Wait 10 seconds for the first image
3: # How can create the LWP::UserAgent object just once?
4: # bizzach@lookiloo.net
5:
6: my $mw = new MainWindow;
7: my $l = $mw->Label(
8: -text => 'Wbscam',
9: -foreground => 'blue',
10: -font => [qw/-size 100 -slant italic/]
11: );
12:
13: $mw->repeat(10000 => \&run);
14:
15: $l->pack();
16: MainLoop;
17:
18: sub run {
19: my $bytes = get_photo();
20: my $photo_data = encode_base64($bytes);
21: my $photo = $mw->Photo(-data => $photo_data,
22: -format => "jpeg");
23: $l->configure(-image => $photo);
24: }
25:
26: sub get_photo {
27: my $ua = LWP::UserAgent->new(timeout => 30,
28: keep_alive => 1);
29:
30: my $r = $ua->get('http://fiver.homeunix.com/images/webcam.jpg');
31: my $content;
32:
33: if ($r->is_success) {
34: $content = $r->content;
35: }
36: return $content;
37: }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Webcam snapshot viewer
by Aristotle (Chancellor) on Nov 18, 2002 at 00:35 UTC |