Importing Tkinter

This section describes the different styles of importing Tkinter modules. In the preceding example, we imported Tkinter by using the following command:

from tkinter import *

This method of importing eases the handling of methods defined in the module. That is to say, you can simply access the methods directly. Generally, it is considered bad practice to import all (*) the methods of a module like we did here. This is so because this style of importing leads to memory flooding, namespace confusion, and difficulty in bug tracking and/or reviewing code. Importing into the global namespace can also lead to an accidental overwriting of methods from other libraries in the global namespace.

There are several ways to import Tkinter in which ...

Get Tkinter GUI Application Development Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.