Stats

97 Contributors: 4 Friday, February 3, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

tkinter

Introduction

Released in Tkinter is Python's most popular GUI (Graphical User Interface) library. This topic explains proper usage of this library and its features.

Remarks

The capitalization of the tkinter module is different between Python 2 and 3. For Python 2 use the following:

from Tkinter import *  # Capitalized

For Python 3 use the following:

from tkinter import *  # Lowercase

For code that works with both Python 2 and 3, you can either do

try:
    from Tkinter import *
except ImportError:
    from tkinter import *

or

from sys import version_info
if version_info.major == 2:
    from Tkinter import *
elif version_info.major == 3:
    from tkinter import *

See the tkinter Documentation for more details

Related Examples