
#Homework website blocker plus
Here we have opened the host file in r+ mode which is read plus write mode. open() – this is for opening the host file.get() – this method is used to get the text that is added to the enter_website label.If the website is already in the host file then a label ‘Already Blocked ’ will be displayed. We have created this block function so that when we add any website to the text area and click on the block button, the website will be added to the host file and will be blocked.Host_file.write(ip_address + " " + web + '\n') With open (host_path, 'r+') as host_file:ĭisplay=Label(window, text = 'Already Blocked', font = 'arial') Website_lists = enter_Website.get(1.0,END) So here we give our local ip address and path of the host file. As we want the websites to be blocked in our system we need to add those websites in the host file.Host Path and IP Address: host_path ='C:\Windows\System32\drivers\etc\hosts' We have used Label() to create the label and pack() to pack the heading label to the window.ģ. Here we have created a Label named heading which is for giving a heading to the window.title() – provides an appropriate title to the window.minsize(), maxsize() – this function is for giving the minimum and maximum size to the window.Geometry() – this function is used to give size to the window.tk()- helps us create an empty window where we can add labels and buttons.Heading=Label(window, text ='Website Blocker', font ='arial') Window.title(" DataFlair Website Blocker") Import * means importing all the methods and functions from the tkinter library.We will only require Tkinter Module to create GUI in Python. Let us start building the python project following the given steps 1.



Creating Block function to block websites.Let us have a look at the steps we will be performing to create the Python Website Blocker project
#Homework website blocker install
To use Tkinter Module we need to install it using the following command: pip install tk Download the Source Codeīefore proceeding with the project, please download the source code of python website blocker from the following link: Website Blocker Project Project File Structure This project requires basic understanding of Python like defining functions, creating loops etc. Python Website Blocker Project Prerequisites These websites are added to the host file of the system. As the names suggest these functions will perform blocking and unblocking of websites respectively. We will be making two functions Block() and Unblock(). While creating Python Website Blocker Application, we are going to use only one module – Tkinter Module to make easy GUI using Python. We will also have an unblock feature added to it so that we can unblock any website in future if we want and Tkinter Module for creating GUI. We are going to create a website blocker using python which will give us a window where we can type the url of the websites and then we can block those websites. This is where a Website Blocker helps us. There are certain times when we face the need to block different websites on our system. Instead of using other applications to block websites on your system, why not create our own website blocker application using Python? Let us master Python by making yet another mini-project.
#Homework website blocker free
Free Python course with 35 real-time projects Start Now!!
