Web broswer using tkinter and webbrowser module
Web Browser. Its a desktop app developed in tkinter. You can search anything here and some famous websites can be searched on one click only.
Modules Used: tkinter, webrowser
Visual Form:
Source Code:
from tkinter import *
import webbrowser
browser = Tk()
browser.title("My Web Browser")
browser.geometry('500x500')
browser.minsize(500,500)
browser.maxsize(500,500)
browser.configure(bg = '#C8C8B0')
browser.wm_iconbitmap('web_icons/icon.ico')
google_icon = PhotoImage(file = 'web_icons/google.png')
youtube_icon = PhotoImage(file = 'web_icons/youtube.png')
gmail_icon = PhotoImage(file = 'web_icons/gmail.png')
facebook_icon = PhotoImage(file = 'web_icons/facebook.png')
fiverr_icon = PhotoImage(file = 'web_icons/fiverr.png')
upwork_icon = PhotoImage(file = 'web_icons/upwork.png')
whatsapp_icon = PhotoImage(file = 'web_icons/whatsapp.png')
twitter_icon = PhotoImage(file = 'web_icons/twitter.png')
instagram_icon = PhotoImage(file = 'web_icons/instagram.png')
tiktok_icon = PhotoImage(file = 'web_icons/tiktok.png')
python_icon = PhotoImage(file = 'web_icons/python.png')
linkedin_icon = PhotoImage(file = 'web_icons/linkedin.png')
skype_icon = PhotoImage(file = 'web_icons/skype.png')
telegram_icon = PhotoImage(file = 'web_icons/telegram.png')
def click_func(event):
widget_text = event.widget.cget('text')
if 'www' not in widget_text:
webbrowser.open(f'www.{widget_text}.com')
elif 'www' in widget_text:
webbrowser.open(widget_text)
else:
pass
heading = Label(browser, text = 'Browse Here What You Want', bg = '#F10031', fg = 'white', font = 'lucida 25')
heading.pack(side = TOP ,fill = 'x')
sites = ['Facebook', 'Youtube', 'Gmail', 'Google', 'Fiverr', 'Upwork', 'Whatsapp']
icons = [facebook_icon, youtube_icon, gmail_icon, google_icon, fiverr_icon, upwork_icon, whatsapp_icon]
x1 = 0
for i in range(len(sites)):
btn = Button(browser, image = icons[i], text = sites[i], bg = '#C8C8B0', relief = FLAT, borderwidth = 5, compound = TOP, fg = 'Black')
btn.place(x = 10 + x1, y = 80)
btn.bind('<Button-1>', click_func)
x1 += 70
heading = Label(browser, text = 'Search Below', bg = '#C8C8B0', fg = 'Black', font = 'lucida 25')
heading.place(x = 150, y = 200)
search_var = StringVar()
search_var.set('')
entry_box = Entry(browser, textvariable = search_var, width = 40, fg = '#F10031', font = 'Arial 15', bg = 'white')
entry_box.place(x = 30, y = 250)
def search_func(event):
webbrowser.open(str(search_var.get()))
search_var.set('')
btn = Button(browser, text = 'SEARCH', bg ='#F10031', fg = 'white', font = 'lucida 15')
btn.place(x = 210, y = 290)
btn.bind('<Button-1>', search_func)
names = ['Twitter', 'Instagram', 'Tiktok', 'Python', 'LinkedIn', 'Skype', 'Telegram']
icons1 = [twitter_icon, instagram_icon, tiktok_icon, python_icon, linkedin_icon, skype_icon, telegram_icon]
x2 = 0
for i in range(len(names)):
btn = Button(browser, image = icons1[i], text = names[i], bg = '#C8C8B0', relief = FLAT, borderwidth = 5, compound = TOP, fg = 'Black')
btn.place(x = 10 + x2, y = 390)
btn.bind('<Button-1>', click_func)
x2 += 70
browser.mainloop()
Comments