Skip to Content
Web, Graphics & Perl/Tk Programming
book

Web, Graphics & Perl/Tk Programming

by Jon Orwant
March 2003
Intermediate to advanced
448 pages
12h 36m
English
O'Reilly Media, Inc.
Content preview from Web, Graphics & Perl/Tk Programming

Chapter 36. The Mouse Odometer

Steve Lidie

If you read Getting Started with Perl/Tk and Scoreboard: A 15-Minute Perl/Tk Application, you should be a seasoned Tk novice by now. Assuming so, let’s move right along and examine the Perl/Tk implementation of the Mouse Odometer, named modo and pictured in Figure 36-1.

modo, the mouse odometer
Figure 36-1. modo, the mouse odometer

modo has got to be one of the most pointless programs ever written. But it illustrates numerous Perl/Tk features, so it does have some value. I first saw similar code for the Mac, written by Sean P. Nolan, that simply tracked a machine’s cursor. Currently I have logged well over 51 kilometers on my cursor, and my mouse has careened around its pad some 14 kilometers.

Measuring Distance

Most of this column is not about modo and how it works, but rather the Perl/Tk features it uses. This time we’ll learn how to schedule asynchronous timer events, and look more closely at window manager commands, menus, menubuttons, and the ColorEditor. We’ll also create and explain in detail an object-oriented Perl/Tk composite widget that we’ll create called the Odometer. Like a car’s odometer, we want our mouse odometer to record the physical distance traveled by the mouse, not the number of pixels. In a car, you want to know how many miles you’ve traveled, not merely the number of tire-lengths, which will vary from car to car. In the X window system you can ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Perl Testing: A Developer's Notebook

Perl Testing: A Developer's Notebook

Ian Langworth, Chromatic
Higher-Order Perl

Higher-Order Perl

Mark Jason Dominus

Publisher Resources

ISBN: 9781449398590Errata Page