0% found this document useful (0 votes)
16 views47 pages

Unit 4: GUI Development Using Python

Uploaded by

XYZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views47 pages

Unit 4: GUI Development Using Python

Uploaded by

XYZ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

Unit 4

GUI Development using


Python
Topics
• Introduction,
• TKinter programming,
• Widgets,
• Controlling window Geometry,
• Event handling
Introduction
• Python provides various options for
developing graphical user interfaces
(GUIs). Most important are listed below.
▫ Tkinter: Tkinter is the Python interface to
the Tk GUI toolkit shipped with Python.
▫ wxPython: is an open-source Python
interface for wxWindows
▫ JPython: JPython is a Python port for Java
which gives Python scripts seamless access
to Java class libraries on the local machine
If Tkinter is the Python interface
to the Tk GUI toolkit, what is Tk?

• Tk started life as Tcl extension (1991). It is


now written in C.
• Tk is a high-level windowing toolkit. You
can interface with it directly using C or
other languages.
• Tk interfaces are also available in Python,
Ruby, Perl, Tcl, and probably other
languages.
• Tk provides a high-level means of accessing
your system's windowing infrastructure.
What is Tkinter ?

• Tkinter is the standard GUI library


for Python.
• Python when combined with Tkinter
provides a fast and easy way to
create GUI applications.
• Tkinter provides a powerful object-
oriented interface to the Tk GUI
toolkit.
What is Tkinter ?

• Tkinter is included with Python as a


library. To use it:
▫ import * from Tkinter
• or
▫ from Tkinter import *
What can it do?

• Tkinter gives you the ability to create


Windows with widgets in them

• Widget is a graphical component on the


screen (button, text label, drop-down
menu, scroll bar, picture, etc…)

• GUIs are built by arranging and


combining
different widgets on the screen.
How to create a GUI using Tkinter ?

• Following steps are to be performed −


▫ Import the tkinter module.
▫ Create the GUI application main window.
▫ Add one or more widgets to the GUI
application.

• Enter the main event loop to take action


against each event triggered by the user.
Our first Tkinter program
Output
Tkinter Features
Quiz
• Create an application which:
▫ Consists of a single button.
▫ On the button is an image. Start with
"Happy.jpg".
▫ When the button is pressed the image
changes to "Sad.jpg".
▫ When the button is pressed again the
image changes back to "Happy.jpg".
▫ And so on.
• Hint: use the Button's '.configure(image =
newimage)' to change the image.
Geometry Managers

You might also like