Skip to content

Commit 2355f99

Browse files
committed
Added Network Usage Tracker in GUIScripts
1 parent 528a368 commit 2355f99

File tree

12 files changed

+176
-0
lines changed

12 files changed

+176
-0
lines changed
90.7 KB
Loading
143 KB
Loading
148 KB
Loading
139 KB
Loading
136 KB
Loading
148 KB
Loading
150 KB
Loading
136 KB
Loading
Loading
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ✔ NETWORK USAGE TRACKER
2+
- ### A "Network Usage Tracker" is an application created in python with tkinter gui.
3+
- ### In this application, user gets the usage of network in his/her PC or computer at every instant.
4+
- ### Here user will be given a MAX LIMIT of network usage, and if user crosses that max limit, user willl be notified for the same.
5+
- ### Also user will be able to see the connection status and the IP address related to the same.
6+
7+
****
8+
9+
# REQUIREMENTS :
10+
- ### python 3
11+
- ### tkinter module
12+
- ### from tkinter messagebox module
13+
- ### from pil import ImageTk, Image
14+
- ### time
15+
- ### psutil
16+
- ### socket
17+
18+
****
19+
20+
# How this Script works :
21+
- ### User just need to download the file and run the netwoek_usage_tracker.py on their local system.
22+
- ### Now a GUI window will open, where user will option like START and EXIT.
23+
- ### When user clicks on the START button, user will be directed to the main application os network usage tracker.
24+
- ### Here user gets the usage of network in his/her PC or computer at every instant.
25+
- ### Here user will be given a MAX LIMIT of network usage, and if user crosses that max limit, user willl be notified for the same.
26+
- ### Also user will be able to see the connection status and the IP address related to the same.
27+
- ### Also there is an exit button, clicking on which exit dialog box appears asking for the permission of the user for closing the window.
28+
29+
# Purpose :
30+
- ### This scripts helps us to easily get the instant usage of network in his/her PC or Computer.
31+
32+
# Compilation Steps :
33+
- ### Install tkinter, pil, time, psutil, socket
34+
- ### After that download the code file, and netwoek_usage_tracker.py on local system.
35+
- ### Then the script will start running and user can monitor the network usage and check if it exceeds the max limit or not.
36+
****
37+
38+
# SCREENSHOTS :
39+
40+
****
41+
42+
<p align="center">
43+
<img width = 1000 src="Images/1.jpg" /><br>
44+
<img width = 1000 src="Images/2.jpg" /><br>
45+
<img width = 1000 src="Images/3.jpg" /><br>
46+
<img width = 1000 src="Images/4.jpg" /><br>
47+
<img width = 1000 src="Images/5.jpg" /><br>
48+
<img width = 1000 src="Images/6.jpg" /><br>
49+
<img width = 1000 src="Images/7.jpg" /><br>
50+
<img width = 1000 src="Images/8.jpg" /><br>
51+
</p>
52+
53+
****
54+
55+
# Name :
56+
- ### Akash Ramanand Rajak
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
# NETWORK USAGE TRACKER
3+
4+
# imported necessary library
5+
from tkinter import *
6+
import tkinter as tk
7+
import tkinter.messagebox as mbox
8+
from pil import ImageTk, Image
9+
import time
10+
import psutil
11+
import socket
12+
13+
# Main Window & Configuration
14+
window1 = tk.Tk() # created a tkinter gui window frame
15+
window1.title("Network Usage Tracker") # title given is "DICTIONARY"
16+
window1.geometry('1000x700')
17+
18+
# top label
19+
start1 = tk.Label(text = "NETWORK USAGE\nTRACKER", font=("Arial", 55,"underline"), fg="magenta") # same way bg
20+
start1.place(x = 150, y = 10)
21+
22+
def start_fun():
23+
window1.destroy()
24+
25+
# start button created
26+
startb = Button(window1, text="START",command=start_fun,font=("Arial", 25), bg = "orange", fg = "blue", borderwidth=3, relief="raised")
27+
startb.place(x =130 , y =590 )
28+
29+
# image on the main window
30+
path = "Images/front.png"
31+
# Creates a Tkinter-compatible photo image, which can be used everywhere Tkinter expects an image object.
32+
img1 = ImageTk.PhotoImage(Image.open(path))
33+
# The Label widget is a standard Tkinter widget used to display a text or image on the screen.
34+
panel = tk.Label(window1, image = img1)
35+
panel.place(x = 320, y = 200)
36+
37+
# function created for exiting
38+
def exit_win():
39+
if mbox.askokcancel("Exit", "Do you want to exit?"):
40+
window1.destroy()
41+
42+
# exit button created
43+
exitb = Button(window1, text="EXIT",command=exit_win,font=("Arial", 25), bg = "red", fg = "blue", borderwidth=3, relief="raised")
44+
exitb.place(x =730 , y = 590 )
45+
window1.protocol("WM_DELETE_WINDOW", exit_win)
46+
window1.mainloop()
47+
48+
# main window created
49+
window = Tk()
50+
window.title("Network Usage Tracker")
51+
window.geometry("1000x700")
52+
53+
# top label
54+
top1 = Label(window, text="NETWORK USAGE\nTRACKER", font=("Arial", 50,'underline'), fg="magenta")
55+
top1.place(x = 190, y = 10)
56+
57+
top1 = Label(window, text="MAX LIMIT : 1 MB/sec", font=("Arial", 50), fg="green")
58+
top1.place(x = 130, y = 180)
59+
60+
# text area
61+
path_text = Text(window, height=1, width=24, font=("Arial", 50), bg="white", fg="blue",borderwidth=2, relief="solid")
62+
path_text.place(x=50, y = 300)
63+
64+
# l1 = Label(window, fg='blue', font=("Arial", 50))
65+
# l1.place(x = 80, y = 300)
66+
67+
top1 = Label(window, text="Connection Status :", font=("Arial", 50), fg="green")
68+
top1.place(x = 200, y = 450)
69+
70+
l2 = Label(window, fg='blue', font=("Arial", 30))
71+
l2.place(x = 200, y = 530)
72+
73+
def convert_to_gbit(value):
74+
return value/1024./1024./1024.*8
75+
76+
# function defined to update the usage instantly
77+
old_value = 0
78+
def update_label():
79+
global old_value
80+
new_value = psutil.net_io_counters().bytes_sent + psutil.net_io_counters().bytes_recv
81+
# if old_value:
82+
# send_stat(new_value - old_value)
83+
x = "{0:.3f}".format(new_value - old_value)
84+
# l1.configure(text="")
85+
# l1.configure(text= "Usage : " + str(x) + " bytes/sec")
86+
path_text.delete("1.0", "end")
87+
path_text.insert(END, "Usage : " + str(x) + " bytes/sec")
88+
89+
# for updating connection status
90+
IPaddress = socket.gethostbyname(socket.gethostname())
91+
if IPaddress == "127.0.0.1":
92+
l2.configure(text="No internet, your localhost is\n" + IPaddress)
93+
else:
94+
l2.configure(text="Connected, with the IP address\n" + IPaddress)
95+
96+
# for checking max limit exceeded
97+
if(new_value - old_value>1000000):
98+
mbox.showinfo("Exceed Status", "Max Limit Usage Exceeded.")
99+
100+
old_value = new_value
101+
102+
time.sleep(0.5)
103+
window.after(1, update_label)
104+
105+
update_label()
106+
107+
108+
# function for exiting window
109+
def exit_win():
110+
if mbox.askokcancel("Exit", "Do you want to exit?"):
111+
window.destroy()
112+
113+
window.protocol("WM_DELETE_WINDOW", exit_win)
114+
window.mainloop()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
libraries used : tkinter
2+
messagebox
3+
pil
4+
time
5+
psutil
6+
socket

0 commit comments

Comments
 (0)