-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsite blocker.py
45 lines (31 loc) · 1.28 KB
/
website blocker.py
1
from tkinter import *# create a display windowroot=Tk()root.geometry('500x500')root.resizable(0,0)root.title("Anurag website blocker")Label(root,text="Website Blocker",font='arial 20 bold').pack()Label(root,text="Made by Anurag",font='arial 20 bold').pack(side=BOTTOM)#create an entry widgethost_path='c:\windows\system32\drivers\etc\hosts'ip_address = '127.0.0.1'Label(root,text='Enter Website: ',font='arial 13 bold').place(x=5,y=60)websites =Text(root,font='arial 10',height='2',width='40',wrap=WORD,padx=5,pady=5)websites.place(x=140,y=60)#define Functionsdef Blocker(): website_lists=websites.get(1.0,END) website=list(website_lists.split(",")) with open(host_path,'r+')as host_file: file_content=host_file.read() for website in website: if website in file_content: Label(root,text="Already Blocked",font='arial 12 bold').place(x=200,y=200) pass else: host_file.write(ip_address+ " "+website+ '\n') Label(root,text="Blocked",font='ariel 12 bold').place(x=230,y=200)#create a block buttonblock =Button(root,text="Block",font='ariel 12 bold',pady=5,command=Blocker,width=6,bg='royal blue1',activebackground='skyblue')block.place(x=230,y=150)root.mainloop()