adsterra

Search Bar using Python Programming with source code|Python Tkinter


 Search Bar 




In this article we are going to build a Search Bar with the help of Tkinter module(to build Graphical User Interface),Webbrowser module (to open a web browser)Using python it is very easy to open up a web Browser and make a Search Bar.
Tkinter :-
tkinter is a GUI library of python for building a Graphical Interface for users. However  there are alot of other packages that provide the GUI interface in python ,But tkinter is the most commonly used library.It provide the powerful interface to the Tk GUI  toolkit. In this article we are going to make a Search Bar with the help of Tkinter.
There are two way to import tkinter module:
1.import tkinter
2.from tkinter import *

Webbrowser:
The webbrowser module of python provides a high-level interface to allow displaying Web-based documents to users. Using it to open a browser is very simple, just call the open() function from this module will open url using the default browser . You have to import the module and use open() function. 

Here we go with two different methods to use this module:
1.with Tkinker(Graphical user Interface)
2.without Tkinter

1.Using Tkinter:
Steps:
from tkinter import *
import webbrowser
root=Tk()
root.title("Search Bar")
def search():
    url=entry.get()
    webbrowser.open(url)
lable1=Label(root,text="Enter URL here :   ",font=("arial",15,"bold"))
lable1.grid(row=0,column=0)
entry=Entry(root,width=35)
entry.grid(row=0,column=1)
btn=Button(root,text="Search",command=search,bg="blue",fg="white",font=("arial",14,"bold"))
btn.grid(row=1,column=0,columnspan=2,pady=10)
root.mainloop()

2.Simplest use of webbrowser
import webbrowser
webbrowser.open('https://csafact.blogspot.com')

Post a Comment

0 Comments