O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

tkmpg123

The tkmpg123 program is an MPG player based on Apple’s itunes. The explanation and demonstration can be found in Chapter 15.

#!/usr/local/bin/perl -w # # tkmpg123 - keep mpg123 and Tk happily eventing w/o blocking. # # Stephen.O.Lidie@Lehigh.EDU, 2001/04/17. use Audio::Play::MPG123; use Tk; use Tk::PNG; use subs qw/build_player start_play edit_menuitems file_menuitems help_menuitems init play/; our ($c, , @info, $infov, $mw, $paus, $phand, $play, $player, $timev, $v); use strict; $v = '-0.97'; $player = Audio::Play::MPG123->new; $phand = $player->IN; $mw = MainWindow->new; $mw->configure(-menu => my $menubar = $mw->Menu); map {$menubar->cascade( -label => '~' . $_->[0], -menuitems => $_->[1] )} ['File', file_menuitems], ['Edit', edit_menuitems], ['Help', help_menuitems]; build_player; MainLoop; sub build_player { $c = $mw->Canvas( -width => 1, -height => 1, -background => 'dark slate gray', )->pack; my $itunes = $c->Photo(-file => 'images/itunes.gif'); $c->createImage(0, 0, -image => $itunes, -tag => 'itunes', -anchor => 'nw', ); $c->configure(-width => $itunes->width, -height => $itunes->height); $paus = $c->Photo(-file => 'images/paus.gif'); $play = $c->Photo(-file => 'images/play.gif'); $c->createImage(80, 40, -image => $play, -tag => 'play-image'); $c->bind('play-image', '<1>' => \&pause); my $green = '#d5dac1'; my $font = 'courier 12'; my $f = $c->Frame( -width => 250, -height => 50, -background => $green, -relief => 'sunken', -borderwidth => 3, ); $f->packPropagate(0); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required