Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Build a GUI Application to ping the host using Python

  • Last Updated : 04 Dec, 2021

Prerequisite: Python GUI – Tkinter

In this article, we are going to see how to ping the host with a URL or IP using the python ping module in Python. This module provides a simple way to ping in python. And It checks the host is available or not and measures how long the response takes.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

“Before” starting we need to install this module into your system.

pip install pythonping

The GUI would look like below:

Syntax: ping(‘URL or IP’)


  • verbose : enables the verbose mode, printing output to a stream
  • timeout : is the number of seconds you wish to wait for a response, before assuming the target is unreachable
  • payload : allows you to use a specific payload (bytes)
  • size : is an integer that allows you to specify the size of the ICMP payload you desire



# import module
from pythonping import ping
# pinging the host
ping('', verbose=True)


Reply from, 9 bytes in 61.09ms
Reply from, 9 bytes in 60.24ms
Reply from, 9 bytes in 60.22ms
Reply from, 9 bytes in 60.04ms
Reply from, 9 bytes in 61.09ms
Reply from, 9 bytes in 60.24ms
Reply from, 9 bytes in 60.22ms
Reply from, 9 bytes in 60.04ms

Round Trip Times min/avg/max is 60.04/60.4/61.09 ms

Implementation for GUI:

Pinging GUI Application with Tkinter


# import modules
from tkinter import *
from pythonping import ping
def get_ping():
    result = ping(e.get(), verbose=True)
# object of tkinter
# and background set for light grey
master = Tk()
master.configure(bg='light grey')
# Variable Classes in tkinter
res = StringVar()
# Creating label for each information
# name using widget Label
Label(master, text="Enter URL or IP :",
      bg="light grey").grid(row=0, sticky=W)
Label(master, text="Result :", bg="light grey").grid(row=1, sticky=W)
# Creating label for class variable
# name using widget Entry
Label(master, text="", textvariable=res, bg="light grey").grid(
    row=1, column=1, sticky=W)
e = Entry(master)
e.grid(row=0, column=1)
# creating a button using the widget
# Button that will call the submit function
b = Button(master, text="Show", command=get_ping)
b.grid(row=0, column=2, columnspan=2, rowspan=2, padx=5, pady=5)


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!