
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programmatically Opening URLs in a Web Browser Using Python Tkinter
Python has a rich library of extensions and modules which are used for multiple purposes. To work with web-based content, Python provides a webbrowser module. The module creates an environment which enables the user to display web-based content in the application. To work with webbrowser, you have to make sure that it is installed in your local machine.
import webbrowser
If the module is not available in your environment, then you can install it using the following command −
pip install webbrowser
Example
Using the webbrowser module in our program, we will open an URL in our web browser. To open the URL in a default browser, we can use the open() function in the module.
# Import the required libraries import webbrowser # Add a URL to open in a new window url= 'https://www.tutorialspoint.com/' # Open the URL in a new Tab webbrowser.open_new_tab(url)
Output
Running the above code will open the given URL in a new window of the default browser.
Advertisements