O'Reilly logo

Practical Programming in Tcl and Tk, Fourth Edition by Brent Welch, Ken Jones

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

Chapter 49. Writing a Tk Widget in C

This chapter describes the implementation of a simple clock widget. Two implementations are shown: the original string-based command interface and the Tcl_Obj command interface.

A custom widget implemented in C has the advantage of being efficient and flexible. However, it requires more work, too. This chapter illustrates the effort by explaining the implementation of a clock widget. It is a digital clock that displays the current time according to a format string. This is something you could implement in several lines of Tcl using a label widget, the clock command, and after for periodic updates. However, the point of the example is to show the basic structure for a Tk widget implemented in C, not how much ...

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