Make a Scoreboard Widget

Make your own scoreboard widget for the Mac OS X Dashboard.

Apple introduced a neat new feature in OS X 10.4, Dashboard, which pops up a set of simple tools with the press of a button. The tools that come with the OS include a clock, an address book, and a stock ticker. This hack shows you how to make your own widget to display live baseball information.

By the way, if you’re using a PC, an application called Konfabulator works almost exactly like Dashboard. (In fact, Konfabulator was originally written for the Mac; Apple probably got the idea for Dashboard from this application.) You can get a copy of this shareware application for about $20 from http://www.konfabulator.com.

The Code

A widget is really just a web page. Well, it’s a deluxe web page, with background images, cascading stylesheets, and JavaScript, but that’s all there is to it. If you’re not afraid of a little simple code, it’s pretty easy to make your own widget.

I decided to show some basic information about each game: the teams playing, the number of runs, the inning, and the number of outs. To fit all of the day’s games into one window, I decided to use two different tables (and in turn, I used iFrame objects to make this work). Here are the files in this widget:

Info.plist

An XML file containing the properties for this widget (Dashboard requires this file or the widget won’t work)

Default.png

A background graphic for the widget (also displayed while the widget is loading); just a big green box ...

Get Baseball Hacks now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.