Tkinter (tkinter in Python 3.x) claims to be "most portable GUI toolkit for Python" and is Python's "de-facto standard GUI (Graphical User Interface) package". Although there are several other graphical toolkits for Python, Tkinter is the one most often used in GUI development with Python.
USE flags for dev-lang/tk Tk Widget Set
||Include support for the Mac OS X Aqua (Carbon/Cocoa) GUI|
||Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces|
||Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)|
||Add threads support for various packages. Usually pthreads|
||Add support for FreeType and/or FreeType2 fonts|
||Add support for XScreenSaver extension|
On Gentoo, getting Tkinter can be accomplished by directly emerging the package and/or by modifying your system's use flags. Since Tkinter is build on tcl and tk, both of which are closely related to Python, you can get the package by updating your system's global use flags and re-emerging Python. Using this method of installation will pull the packages needed to successfully run Tkinter.
First, modify make.conf:
Finally, re-emerge Python using this command:
emerge --ask --oneshot --newuse $(qlist -ICSe dev-lang/python)
That is it! Tkinter should now be installed.
When attempting to use Tkinter in Python code, depending on the version(s) of Python are currently installed on the system, import Tkinter might need performed in different ways:
- When using Python 2.x.: use
- using Python 3.x: use
import tkinter(note the lower case T).