Tkinter

From Gentoo Wiki
Jump to:navigation Jump to:search
This article is a stub. Please help out by expanding it - how to get started.

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.

tkinter uses dev-lang/tk internally.

Installation

make.conf

Getting Tkinter can be accomplished by enabling the tk USE flag. This can be set for specifically for Python, or for all packages system-wide in the make.conf file.

FILE /etc/portage/make.confAdd tk to the system's USE flags
USE="tk"

package.use

For an approach more limited in scope, modify a package.use file for Python only.

FILE /etc/portage/package.use/pythonAdd the tk USE flag for dev-lang/python
dev-lang/python tk

Emerge

Finally, re-emerge the @world set using this command:

root #emerge --ask -uvDU @world

That is it! Tkinter should now be installed.

Usage

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

See also

  • Python — an extremely popular cross-platform object oriented programming language.

External Links