Python Language tkinter

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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



Got any Python Language Question?