![]() The Website Blocker python project has been completed successfully. Host_path ='C:\Windows\System32\drivers\etc\hosts' Label(root, text ='WEBSITE BLOCKER', font ='arial 20 bold').pack() Source Code for Website Blocker in Python Language from tkinter import * When we click the button, Button() is called, which is utilized to show the button on our window command.Īctivebackground – specifies the color of the button's background when it is pressed. When we press the Block button, the Blocker function is invoked. Host_file.write(ip_address + " " + website + '\n') Label(root, text = 'Already Blocked', font = 'arial 12 bold').place(x=200,y=200) With open (host_path, 'r+') as host_file: Make a button that says "Block." def Blocker(): Otherwise, it will ban all of the specified websites and display a label that reads 'Blocked.' 5. Print a label with text previously blocked if the webpage is already in file content. R+ will be used to read and write to a file. comma-separate the content of the lists, then convert it to a list and save it in a website with open – When we are done using the file, the with open statement will automatically terminate the file handler. Website lists website list(lists.split(,"")) returns a list of all the websites that users may input. Websites = Text(root,font = 'arial 10',height='2', width = '40', wrap = WORD, padx=5, pady=5) Label(root, text ='Enter Website :', font ='arial 13 bold').place(x=5 ,y=60) host_path ='C:\Windows\System32\drivers\etc\hosts' Padx adds more room to the widget's left and right sides, while Pady adds extra space to the widget's top and bottom sides.After the final word, wrap = WORD will break the line.For multi-line text fields, the Text() widget is utilized.The IP address used by localhost is saved in ip address.The path to our host file is saved in host path.Root – the name of our window text – the text that appears on the label font – the typeface in which the text is written pack – the organized widget in block 3 Make a widget for entry. The Label() widget is used to show one or more lines of text that users cannot change. Label(root, text ='TechVidvan', font ='arial 20 bold').pack(side=BOTTOM) Geometry() makes the window's width and height resizable (0,0) set the window's fixed dimensionsīg = " is used to set the window's background color, whereas title() is used to set the window's title. Tk() created tkinter, which signifies that a window was formed. We'll use the tkinter library to construct a window where we'll type our text to be converted into voice. Root.title("TechVidvan - Website Blocker") ![]() We use the tkinter library to import modules. How to Make a Website Blocker Project Python: You may use the pip install command at the command line to install the library: pip install tkinter It is one of the quickest and most straightforward methods to create GUI applications using Tkinter. Tkinter is a well-known Python GUI library. The fundamental ideas of Python and the Tkinter library will be used to construct the website blocker project. The user may input numerous websites to block in this Python Website Blocker Project, and then hitting the block button will verify the condition that if the website has already been banned, it will print 'already blocked', else it will block all of the websites and print 'blocked'. This project will assist the user in avoiding distractions by preventing them from accessing web pages on their smartphone. The goal of the Website Blocker python project is to ban certain websites from being accessed from any device. We can ban all websites from undesirable categories to use the internet securely. Website Blocker is a program that blocks access to websites either permanently or on a regular basis.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |