Python GUI Programming

Python GUI Programming provides several different options for writing GUI based programs. These are listed below:

  • Tkinter: It is easiest to start with. Tkinter is Python’s standard GUI (graphical user interface) package. It is the most commonly used toolkit for GUI programming in Python.
  • JPython: It is the Python platform for Java that is providing Python scripts seamless access o Java class Libraries for the local machine.
  • wxPython: It is an open-source, cross-platform GUI toolkit written in C++. It is one of the alternatives to Tkinter, which is bundled with Python.

Here is the description for above mentioned options:

Tkinter Programming:

Tkinter is the most commonly used library for developing Python GUI Programming. It is a standard Python interface to the Tk GUI toolkit shipped with Python. As Tk and Tkinter are available on most of the Unix platforms as well as on the Windows system, developing GUI applications with Tkinter becomes the fastest and easiest. For modern Tk binding, Tkinter is implemented as a Python wrapper for the Tcl Interpreter embedded within the interpreter of Python.

Creating a GUI application using Tkinter is an easy task. All you need to do is perform the following steps:

  • It imports the Tkinter module.
  • It creates the GUI application’s main window.
  • It adds one or more of the above-mentioned widgets to the GUI application.
  • It enters the main event loop to take action against each event triggered by the user.
from tkinter import *

appWindow = Tk()
00 python gui programming

Tkinter Widgets:

Tkinter widgets provide various controls, such as buttons, labels, and text boxes used in a Python GUI Programming application. These controls are commonly called widgets. There are 19 widgets in Tkinter. Given below:

ButtonThe Button used to display buttons in your application.
CheckbuttonThe CheckButton used to display a number of options as checkboxes.
The user can select multiple options at a time.
CanvasThe Canvas used to draw shapes, such as lines, ovals,
polygons and rectangles, in your application.
LabelFrameThe labelFrame (a simple container widget) primary purpose is
to act as a spacer or container for complex window layouts.
SpinboxThe Spinbox a variant of the standard Tkinter Entry widget,
which can be used to select from a fixed number of values.
MessageBoxThis module is used to display message boxes in your applications.
MenuThe Menu used to provide various commands to a user.
These commands are contained inside the Menu button.
ToplevelThe Toplevel used to provide a separate window container.
ScrollbarThe Scrollbar used to add scrolling capability to various widgets,
such as list boxes.
PanedWindowA PanedWindow is a container widget that may contain any
a number of panes arranged horizontally or vertically.
MessageThe Message used to display multiline text fields for
accepting values from a user.
ScaleThe Scale used to provide a slider widget.
MenubuttonThe Menu button used to display menus in your application.
RadiobuttonThe Radiobutton used to display a number of options as radio buttons.
The user can select only one option at a time.
LabelThe Label used to provide a single-line caption for other widgets.
It can also contain images.
EntryThe Entry used to display a single-line text field for accepting values from a user.
ListboxThe Listbox used to provide a list of options to a user.
FrameThe Frame used as a container widget to organize other widgets.

Comments are closed.