Tkinter code using font module can't run from command line? Tkinter code using font module can't run from command line? tkinter tkinter

Tkinter code using font module can't run from command line?


Same here:

 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter as tk >>> tk.font AttributeError: 'module' object has no attribute 'font'

The answer is simple: Python doesn't automagically import all module hierarchies, just because you import the top-level one. Those who do (e.g. os, which will make os.path available) have to explicitly write code for that.

However, as IDLE uses tkinter itself, it has already imported tkinter.font, thus you think you can get away without that import. You can't. Just add import tkinter.font, and it works.