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