03
Jul
12

Tkinter

I feel this is going to be a very short one this time. I’ve been testing out various graphical toolkits and I wanted to write about Tkinter. As a windows/linux user I wanted something that was truly cross platform. At work I use WPF and although I am actually more of a fan of it than most, but it does have the huge drawback of only being available on windows.

One of my friends told me about Tkinter which is a thin layer on top of a TK framework for python. While I am very much still a beginner at GUI programming, Tkinter lets you start quickly and easily. I had just started looking at it and in a very short time I was already starting to apply the MVVM pattern to what I was doing. Now while MVVM isn’t naturally supported by Tkinter it works quite well with it, which I will be blogging about soon. Now my point isn’t that MVVM works with it, it’s more that
it’s so quick to pick up that as soon as I had started playing with it I could try quite complicated things with it.

I do have one annoyance with Tkinter however, because while it is included with a fresh install of python the module name has changed in version 3.0 of python. This mean that you need to import the module like this:

import sys
# renamed module in python 3
if (sys.version_info[:2] < (3,0)):
    from Tkinter import *
else:
    from tkinter import *

This is of course only a mild annoyance but it makes the imports at the top of files look untidy.

Other than that I would recommend anyone who is trying to learn to write a GUI to try Tkinter and if you do I found An Introduction To Tkinter to be a very good resource for it even if it does looks a little dated.

Thanks for reading, and also a slightly belated apology for not posting but I’ve been in France on holiday.

Advertisement

2 Responses to “Tkinter”


  1. November 5, 2012 at 11:09 am

    While it would work, this seems like a strange way of doing things. Presumably you are aware of which version of python you are using in the rest of your code or do you have similar constructs for every other difference in interpreter (print calls etc)?


What did you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Call Me
Endorse davidcorne on Coderwall

Categories

Copyright


© 2013 by David Corne.

Creative Commons License

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.


%d bloggers like this: