Python Programming/GUI

This lesson introduces Python graphical user interfaces using Tkinter.

Objectives and Skills
Objectives and skills for this lesson include:
 * Standard Library
 * Graphical User Interfaces

Readings

 * 1)  Graphical user interface
 * 2)  Platform-independent GUI library
 * 3)  Tkinter

Multimedia

 * 1) YouTube: TkInter Tutorial
 * 2) YouTube: Python tkinter Playlist

The tkinter.Tk Method
The tkinter.Tk method creates a toplevel widget of Tk, which usually is the main window of an application.

The root.title Method
The root.title method sets the window title.

The root.maxsize Method
The maxsize method returns the maximum size available for the window.

The root.geometry Method
The geometry method sets the size and offset in pixels for the window.

The tkinter.scrolledtext Object
The tkinter.scrolledtext object implements a basic text widget with a vertical scroll bar.

The pack Method
The pack method packs widgets into the available window space.

The scrolledtext.insert Method
The scrolledtext.insert method inserts text into the scrolled tex widget.

tkinter scrolledtext Example
The following example demonstrates using tkinter to display a scrolling text window.

tkinter canvas Example
The following example demonstrates using tkinter to draw canvas shapes.

Tutorials

 * 1) Complete one or more of the following tutorials:
 * 2) * TutorialsPoint
 * 3) ** GUI Programming
 * 4) * ZetCode
 * 5) ** Introduction to Tkinter

Practice

 * 1) Modify one or more of the Python Programming/Files activities so that the input is passed from the command line and the output is displayed in a Tkinter scrolledtext window.
 * 2) Modify one or more of the Python Programming/Internet Data activities so that the input is passed from the command line and the output is displayed in a Tkinter scrolledtext window.
 * 3) Modify one or more of the Python Programming/Databases activities so that the input is passed from the command line and the output is displayed in a Tkinter scrolledtext window.

GUI Concepts

 * A graphical user interface (GUI) is type of user interface that allows users to interact with electronic devices through graphical icons and visual indicators such as secondary notation, instead of text-based user interfaces, typed command labels or text navigation.
 * Designing the visual composition and temporal behavior of a GUI is an important part of software application programming in the area of human–computer interaction.
 * The goal of human-computer interaction is to enhance the efficiency and ease of use for the underlying logical design of a stored program, a design discipline named usability.
 * Typically, users interact with information by manipulating visual widgets that allow for interactions appropriate to the kind of data they hold.
 * Large widgets, such as windows, usually provide a frame or container for the main presentation content such as a web page, email message or drawing. Smaller ones usually act as a user-input tool.
 * The most common combination of widget elements in GUIs is the windows, icons, menus, pointer (WIMP) paradigm.
 * A Platform Independent Graphical User Interface package is a software library that a programmer uses to produce GUI code for multiple computer platforms.
 * Most platform-independent Graphical User Interface packages slow the execution of the resulting code, and programmers are largely limited to the feature set provided by the package library.
 * Web browsers offer a convenient alternative to GUI packages for many applications. Web browsers utilize HTML as a presentation layer for applications hosted on a central server, and web browsers are available for most platforms.
 * Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit, and is Python's de facto standard GUI.
 * There are several popular GUI library alternatives available, such as wxPython, PyQt (PySide), Pygame, Pyglet, and PyGTK.
 * A Tkinter top-level window is a window that exists independently on the screen. It will be decorated with the standard frame and controls for the desktop manager. It can be moved around the desktop, and can usually be resized.
 * Widget is the generic term for any of the building blocks that make up an application in a graphical user interface. Examples of widgets: buttons, radiobuttons, text fields, frames, and text labels.

Python GUI

 * The tkinter.Tk method creates a toplevel widget of Tk, which usually is the main window of an application.
 * The root.title method sets the window title.
 * The maxsize method returns the maximum size available for the window.
 * The geometry method sets the size and offset in pixels for the window.
 * The tkinter.scrolledtext object implements a basic text widget with a vertical scroll bar.
 * The pack method packs widgets into the available window space.
 * The scrolledtext.insert method inserts text into the scrolled tex widget.

Key Terms

 * button
 * Any graphical control element that provides the user a simple way to trigger an event.


 * checkbutton
 * A GUI widget that permits the user to make a binary choice, i.e. a choice between one of two possible mutually exclusive options.


 * entry
 * A graphical control element intended to enable the user to input text information to be used by the program.


 * frame
 * A type of box within which a collection of graphical control elements can be grouped as a way to show relationships visually, either because the items are functionally related (such as a radio button), or because they apply to related objects.


 * label
 * A graphical control element which displays text on a form. It is usually a static control; having no interactivity.


 * radiobutton
 * A graphical control element that allows the user to choose only one of a predefined set of options.


 * scrollbar
 * A widget in which continuous text, pictures, or other content can be scrolled in a predetermined direction (up, down, left, or right) on a computer display, window, or viewport so that all of the content can be viewed, even if only a fraction of the content can be seen on a device's screen at one time.


 * window
 * A graphical control element which consists of a visual area containing some of the graphical user interface of the program it belongs to and is framed by window decoration.

Assessments

 * Flashcards: Quizlet: GUI Programming
 * Flashcards: Quizlet: Tkinter
 * Quiz: Quizlet: GUI Programming
 * Quiz: Quizlet: Tkinter