Python 3 Tkinter Script to Download Image From URL & Display it GUI Desktop App
800 views
Jun 3, 2025
Get the full source code of application here:
View Video Transcript
0:00
uh hello guys welcome to this video In
0:02
this video I will show you how to build
0:05
out a tinter desktop application GUI
0:08
desktop application where you can
0:09
download image from a URL Let me open
0:13
this application python app 8 py So as
0:17
soon as I run this application you will
0:19
see the interface will look something
0:20
like this We have this input field where
0:23
you will actually enter the address of
0:25
the image that you want to download Then
0:29
the image will be loaded and will be
0:31
displayed right here And now we also
0:34
have the download button as well So just
0:36
go to the internet and uh
0:40
just load any image And now let's
0:43
suppose I search for a any image right
0:46
here that I want to download Let's
0:48
suppose I copy this image address and
0:52
paste
0:54
it Click on this load image button As
0:57
soon as I do this you will see the image
0:59
will get displayed in the token window
1:03
And now we this activated this button
1:05
has been activated So as soon as I click
1:08
this button now I can select the
1:10
location where we need to save this
1:12
image Click on and now you will see fail
1:16
to save
1:18
image So just make sure that you have an
1:23
extension So let's suppose I take a
1:26
different image for
1:31
example Just make sure that the image
1:34
has an extension So I will simply copy
1:40
this load
1:42
image So you'll see that click on
1:46
download
1:49
image So now you can see image saved to
1:52
this location
1:54
like this I can cross check as well by
1:58
going to the downloads directory You
1:59
will see the image is successfully saved
2:02
So in this easy way guys you can build
2:05
out a very simple application where you
2:07
can actually download image from URL
2:09
inside
2:11
trickinter
2:13
So now I will show you how to build this
2:16
application So all the source code is
2:19
given in the description of the video So
2:21
what I will
2:26
do I will show you this application So
2:29
first of all you need to import all the
2:31
modules which are required for this
2:33
application So we just need to import
2:36
the tokinter package as TK and then from
2:40
this tokinter package we need to import
2:43
the file
2:45
dialogue and the message box and then we
2:48
need to import the URL to image and from
2:52
the pillow library we need to import the
2:56
image and the image TK and then we need
2:58
to import the operating system module
3:01
and then here we need to uh
3:05
initialize max display size which will
3:08
be the size of the window So I will say
3:11
400 by
3:13
400 and
3:15
then after
3:18
that we will actually add widgets on the
3:21
screen So we will have initialize root
3:26
tk is equal to
3:29
tk and then we will be giving the title
3:32
to the window root dot
3:37
title image
3:42
downloader Here you can set the
3:51
geometry like
3:55
this After that we will basically set a
3:59
label where the user can write the
4:02
address of the image So here the user
4:04
will paste the image address So we added
4:08
this in inside the
4:11
interface After that we will have a load
4:15
button Now to see the result we can
4:18
simply call this function root main loop
4:21
So as soon as you run this application
4:23
now you will
4:25
see it will this input field is showing
4:28
right here If you see now after that we
4:31
just need a simple button so that the
4:34
user can submit the form So you will
4:37
have a load button first of all So as
4:40
soon as you click the load image button
4:42
the image will be displayed So now to
4:44
display the image we need an image label
4:48
So we are basically having this image
4:51
label where the image will be displayed
4:54
and after that we will have the download
4:56
button where we can download the image
4:59
So now you can see we have now the
5:01
download
5:02
button download image and we basically
5:05
binded this onclick listener to this
5:07
button So once you click this button uh
5:10
this function will execute which is
5:12
download image So right here So if you
5:17
now we just need to define this function
5:19
which is uh download
5:25
image like this
5:34
So if I try to run this application now
5:37
it will look something like this It is
5:39
saying load image is not defined We also
5:42
need to define this function as
5:53
well So now the interface looks like
5:56
this We have the where the user will
5:59
write Then we have the load image Then
6:02
we download image is disabled by default
6:04
So now what we need to do is that we
6:07
need to go to this function uh the load
6:11
image So inside this function load image
6:15
we will load the image once the user
6:18
clicks this button So we will have
6:23
this declare some variables Then we will
6:26
get the value of
6:32
this After that we will display
6:35
this inside this
6:41
try URL to image dot
6:47
convert
6:55
URL After that we will preview the image
6:59
For previewing the image we have this
7:01
function which is pil
7:05
image
7:08
copy And now we will just display this
7:10
image like a simple thumbnail as a live
7:23
preview Yeah So just after this we can
7:26
display this as a thumbnail
7:46
So if you run this now you will see as
7:49
soon as
7:50
you paste any sort of address let's
7:54
suppose I copy image address and I paste
7:58
it all the script guys is given in the
8:01
description of the video so don't need
8:02
to worry about it all the source code is
8:05
given in the description So now we now
8:08
need to basically write this function
8:10
for download image So as soon as I click
8:13
this button I need to open a window so
8:16
that I can download the image
8:22
So right
8:23
here inside download image we will
8:30
specify use the file dialogue module ask
8:38
directory If no folder is selected then
8:41
we will simply
8:42
return because we do need to select a
8:45
folder So now inside the try
8:48
catch we will get the file name by
8:51
operating
8:53
system.path base name URL entry dot get
8:59
So with this easy way we can get
9:07
this like
9:15
this So after getting the file name it
9:18
becomes really easy to actually save
9:22
this image so at the appropriate
9:25
location
9:29
So like
9:32
this then we can display a simple
9:35
notification that your image has been
9:37
saved to this location And uh then we
9:40
use this operating system path join
9:42
method to save this like this Then we
9:46
use the pillow library to save the
9:47
location at that specific path So this
9:51
completes your application And if I try
9:53
to refresh and rerun the
9:59
application So once again just repeat
10:02
the
10:13
process You can see you can select your
10:16
location and then this image has been
10:19
saved So this is actually the
10:21
application guys You can definitely make
10:23
it very easily inside the tweeter image
10:28
downloader You can download images from
10:31
URL inside this Python qu kind of an
10:33
application inside Twinter Uh thank you
10:36
very much guys for watching this video
10:37
Please hit that like button subscribe
10:39
the channel and also check out my
10:42
website freemediattools.com
10:44
uh which contains thousands of tools
#Programming
#Scripting Languages
#Software