From Gentoo Wiki
Jump to:navigation Jump to:search

Tkinter (tkinter in Python 3.x) claims to be "most portable GUI toolkit for Python"[1] and is Python's "de-facto standard GUI (Graphical User Interface) package"[2]. Although there are several other graphical toolkits for Python, Tkinter is the one most often used in GUI development with Python.


USE flags

USE flags for dev-lang/tk Tk Widget Set

aqua Include support for the Mac OS X Aqua (Carbon/Cocoa) GUI
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
threads Add threads support for various packages. Usually pthreads
truetype Add support for FreeType and/or FreeType2 fonts
xscreensaver 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 package.use:

FILE /etc/portage/package.useAdd tk to the system's USE flags for dev-lang/python
dev-lang/python tk


Finally, re-emerge @world using this command:

root #emerge --ask -uvDU @world

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 import Tkinter
  • using Python 3.x: use import tkinter (note the lower case T).

External Links