-
Notifications
You must be signed in to change notification settings - Fork 72
Section 1 Introduction
This section informs the students of any Python prerequisites, and introduces them to Tkinter. After ensuring that Tkinter is working, the students create a number of iterations on a "Hello, World!" application to explore the basic building blocks of working with Tkinter.
There are in fact two libraries called Tkinter: one written for use with Python 2, and the other written for use with Python 3. They are not compatible, and this course is specifically concerned with tkinter
: the Python 3 library.
A common mistake I anticipate is that students will attempt to import Tkinter
, rather than tkinter
, which will result in a ModuleNotFoundError
.
In Tk version 8.5, a new feature called Tk Themed Widgets was added. This basically added theming support to Tk, allowing it to properly emulate the looks and feel of different operating systems. This course is going to make use of the newer, far nicer looking Ttk widgets, and so it is vital that students are using a modern version of Tk.
There are two ways to check that Tk is both working correctly, and that an appropriate version of Tk is installed.
The first is to type the following into terminal: python -m tkinter
Some operating systems may require python3 -m tkinter
instead.
The above command should open a new window with a version number and several buttons. The version number should read at least Tcl/Tk version 8.5
, but more than likely it will read Tcl/Tk version 8.6
.
The other option is to create a simple test app as follows:
import tkinter
tkinter._test()
The output should be the same as using the command line version above.