Good-looking Tk

Game engine illustrates toolkit advantages

Tk looks good. I've had a lot of conversations over the last week, in response to the earlier entries, "Tk is my favorite toolkit" and "Take advantage of Tk", in this series on the toolkit. I recognize there are sincere people who truly find it unsatisfying or even "ugly". After looking over the evidence this week, though, I just don't get it: Tk looks fine to me.

Let's wrap up the current dialogue on Tk for now with a few graphical examples. Then I'll explain a bit of my philosophy in graphical user interface (GUI) work with illustrations from Tk, which also will serve as a foundation for next week's series on my other favorite GUI toolkit. Keep your comments coming; I'm likely to return to the subject of Tk early in 2010, and, in the meantime, I'll answer specific questions in the comments below.

Good-looking graphics

What do I mean when I praise Tk's appearance? Steve Havelka's Brick illustrates my point nicely. Brick is an engine for lo-fi

games:hat0:media:zkm.png
video games; it's not designed to stun you with breath-taking animation or subtle ray-tracing (although it probably could be extended in those directions). Brick is impressive, though, in achieving pleasing effects with just a few lines of code. It makes prototyping a complete game a realistic project for an evening.

Tk's expressivity also helps with basic widgetry. As best I can tell, many of Tk's critics are looking at old, old applications; they completely miss out on the theming

themes.png
that Tk has enabled for several years.

GUI intelligence

Much of my own attention in working with GUIs, as I've already mentioned, goes to what I call "intelligence", or, if you prefer, "civility". A good GUI should adjust in real time to be a good partner to the human user trying to make the most out of it. "Graying out" (disabling) selections that don't make sense at the moment is intelligent; teasing a user with menu choices, only to tell him or her, "you don't have permission to view this now", is simply rude.

While this general idea of interface intelligence is now common in development circles, far less well-known are Tk's tags and traces, constructs which are almost unique to Tcl, but powerful in expressing and programming the flexibility and intelligence a good GUI should have. Also, Tk's "everything is a string" basis encourages everything to be exposed as programmable, in a way that often seems a challenge for object-oriented styles. If there's interest, "Smart Development" might explore more of the declarative possibilities for GUI work through such a different foundation as Flapjax.

Conclusion

I emphasize a final time: you can find out how good Tk feels for yourself in only a few minutes. If you're at a Mac OS keyboard, Tk is already installed, and the same is true for most Linux distributions; even under Windows, installation of everything you need to get started only takes a single quick download.

Tk isn't unique, of course; there's plenty to like about Qt and several other toolkits. Next week, starting tomorrow, I'll explain why we're at a particularly exciting time for development of Web-based applications with HTML5.

From CIO: 8 Free Online Courses to Grow Your Tech Skills
Join the discussion
Be the first to comment on this article. Our Commenting Policies