Sat 12 May 2012
I recently bought Modern Tkinter for Busy Python Developers by Mark Roseman from Amazon and just finished it yesterday. I think it’s pretty new, but I can’t find the release date for it now. Anyway, let’s get on with the review!
- Why I picked it up: I bought this book because I’d been planning to dig into other Python GUI toolkits anyway and I haven’t seen a new Tkinter book since John Grayson’s Python and Tkinter Programming
- Why I finished it: It has a pretty good writing style, although the widgets chapters started to drag
- I’d give it to: Anyone wanting to make their Tkinter applications look more native or learn a little about Tkinters new theming system.
From what I can tell, this is another mobi book for the Amazon Kindle or whatever else accepts mobi. According to Amazon, it would print out to about 147 pages and it’s just under a megabyte in size.
Chapters 1 and 2 are introductory and give some background information on the project. Chapter 3 is just about installing Tkinter, which I don’t really understand. However, this book makes a big deal about the new ttk part of Tkinter and how it’s only available in Python 2.7 and 3.x. It should be noted that after mentioning 2.7 once, the author acts like ttk is only available for 3.x, which is confusing and erroneous. You can actually download it for versions before 2.7, but it comes with 2.7 by default (on Windows anyway).
Anyway, Chapters 4 and 5 cover introductory Tkinter concepts. Chapters 6 and 8 are widget related with 7 talking about the Grid Geometry Manager. Chapter 9 covers menus; 10 goes over Windows and Dialogs; 11 is organizational (notebooks, paned windows, etc); 12 is on Fonts, Colors and Images. Chapters 13-15 cover big widgets: the Canvas, Text, and Tree widgets respectively. The last chapter, 16, talks about theming your application.
As I already mentioned, this book is written in an engaging manner. I had heard that you could make Tkinter look good, but the new stuff in Tk 8.5+ (included in Python 2.7+) makes it sound a lot easier to make your applications look good. The ttk widgets are themed in such a way that they look native or close to it and because of the new theming capabilities, it sounds like you can actually theme it fairly easy.
The bad things I noticed are a few instances where there are PYTHONTODO statements in the text. I assume the author meant to write more at those spots and just forgot to remove those. There’s a part in Chapter 6 about ComboBoxes that sounds like you’ll be able to associate data with the items in the list. The author states that he’ll discuss it later on in the Listbox section, but it turns out that Tkinter doesn’t provide a way to do this at all. You have to come up with your own way and while the author describes some ideas, he doesn’t demonstrate them. I thought it might be something like wxPython builtin way of doing this sort of thing, which I wrote about here, but that is not the case. Oh well.
Some of the ways you’re supposed to set Tkinter settings were unclear and written rather oddly, usually something like this: “step ?amount?”. I’m not really sure if the question marks are required or not, but I’m guessing not. Usually when settings were mentioned, there were no examples to go with them to see how they worked. After reading all this and seeing some of the odd ways you configure Tkinter widgets or instantiate them, I continue to think that it’s pretty unintuitive and inconsistent.
On the other hand, I thought the book covered a lot of good information in a short amount of time. I feel inspired to try Tkinter again just to see what it can do and also because I want to write a couple articles about it. My verdict? If you want to learn the new stuff about ttk, this book makes sense. There’s nothing on the market that I’m aware of that covers this information besides the official documentation. Just note that there are very few full examples and the theme chapter never actually shows how to create your own theme, it just gives you enough information to do it. So if you’re a new Python GUI developer and you want to use Tkinter, then this is probably the book for you.
Update (5/31/2012): This article has been re-formatted and reprinted over on I-Programmer