
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 in 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.
- Related Questions & Answers
- Convenient Web-browser controller in Python
- Opening and reading a file with askopenfilename in Tkinter?
- Difference between Web Browser and Web Server.
- Coolnovo a web browser similar to google chrome
- How to check web browser support in HTML5
- urllib.parse — Parse URLs into components in Python
- Difference Between Search Engine and Web Browser
- Opening and Closing Files in Python
- How to programmatically empty browser cache with HTML?
- How does selenium interact with the Web browser?
- Monitors linux server performance remotely using web browser
- Exposing xsjs file data through web browser in SAP HANA
- How to change the color of a Tkinter label programmatically?
- How can I turn on error information in my Web Browser?
- Pull down to refresh on the mobile web browser in HTML.
Advertisements