CS22-OOP2(Object Oriented Programming 2)
College of Computer Studies
I. INTRODUCTION
In this lesson.
II. OBJECTIVES
1. Define and understand key GUI concepts such
Module 8 as widgets, frames, and event-driven
programming. Explain the advantages of
using a GUI for application development.
GRAPHIC USER 2. Understand the basics of Tkinter, the
standard GUI toolkit for Python.
INTERFACE (G.U.I) 3. Understand how to use pack, grid, and place
geometry managers to organize widgets
within a GUI. Create and customize simple
widgets.
III. PRELIMINARY ACTIVITIES
Recap on previous topic and identify its relation with the next lesson.
IV. LESSON PROPER
PYTHON GUI’S (GRAPHICAL USERS INTERFACES)
There is a long list of GUI frameworks and toolkits, designer tools
• we will only briefly look at Tkinter
GUI are, opposed to a text terminal, easier to use, more intuitive and flexible
Windows, icons, menus, buttons, scroll bards mouse / touch / keyboard
interaction etc.
Operating system (e.g., Windows, macOS, iOS, Linux, Android) can provides basic
functionality in particular a windows manager
Writing GUI applications from scratch can be painful – frameworks try to provide
all standard functionality.
TKINTER
“Tkinter is Python's de-factor standard GUI (Graphical User Interface) package. It
is a thin object-oriented layer on top of Tcl/Tk.”
Page 1 of 2
CS22-OOP2(Object Oriented Programming 2)
College of Computer Studies
“Tcl is a high-level, general-purpose, interpreted, dynamic programming
language.”
“Tk is a free and open-source, cross-platform widget toolkit that provides a
library of basic elements of GUI widgets for building a graphical user interface
(GUI) in many programming languages.”
“The popular combination of Tcl with the Tk extension is referred to as Tcl/Tk,
and enables building a graphical user interface (GUI) natively in Tcl. Tcl/Tk is
included in the standard Python installation in the form of Tkinter.”
TERMINOLOGY
widgets (e.g. buttons, editable text fields, labels, scrollbars, menus, radio
buttons, check buttons, canvas for drawing, frames...)
events (e.g. mouse click, mouse entering/leaving, resizing windows, redraw
requests, ...)
listening (application waits for events to fired)
event handler (a function whose purpose is to handle an event, many
triggered by OS/Window manager)
geometry managers (how to organize widgets in a window: Tkinter pack, grid,
place)
V. PRACTICE EXERCISES/ACTIVITIES
VI. ADDITIONAL RESOURCES
VII. ASSESSMENT
VIII. REFERENCES
Allen B. Downey, ``Think Python: How to Think Like a Computer Scientist‘‘, 2nd edition, Updated
for Python 3, Shroff/O‘Reilly Publishers, 2016
[Link]
Page 2 of 2