URL Opening Application Using Python

URL Opening Application Using Python

Python provides a module "webbrowser" to open any url.

To open any URL using this module, we need to type the URL inside function after the webbrowser. See how

webbrowser.open("url")

So, any URL we will type here will automatically be opened during the running of the program.

We have tried to make this simple program some interesting i.e. we have combined the program with the GUI library of Python i.e. tkinter.

assignment advertisement

We will understand the program using comments as usual.


Code

# importing webbrowser module
import webbrowser
# importing tkinter
from tkinter import *

# creating root
root = Tk()
# setting GUI title
root.title("WebBrowser")
# setting GUI geometry
root.geometry("300x200")


# function to open copyassignment.com in browser
def copyassignment():
    webbrowser.open("www.copyassignment.com")


# function to open google in browser
def google():
    webbrowser.open("www.google.com")


# button to call copyassignment function
copyassignment = Button(root, text="visit copyassignment", command=copyassignment).pack(pady=20)
# button to call google function
mygoogle = Button(root, text="open Google", command=google).pack(pady=20)
root.mainloop()

If you will click on the buttons the corresponding URL will get open automatically in your browser.


Share:
Avatar of Harry

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at [email protected] Thank you

1 thought on “URL Opening Application Using Python

Comments are closed.